#c#sdl2 为什么这个函数不能调用??求解
三山三? 2019-04-17 10:40:15 重点是两个printf的地方,为什么可以输出1,不能输出2??
#include"SDL.h" //一个BMP格式的图片自动向右下角 开始移动,碰到窗口之后,弹开
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
int a = 1, b = 1;
SDL_Rect rect;void aaBS();
int main(int argc,char* argv[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("automove", 100,100, 800, 600, SDL_WINDOW_SHOWN);
SDL_Surface* surface = SDL_GetWindowSurface(window); SDL_Surface* mesurface = SDL_LoadBMP("me.bmp"); SDL_Renderer* rend = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); SDL_Texture* me = SDL_CreateTextureFromSurface(rend,mesurface); SDL_Event event; SDL_RenderClear(rend);
rect.x = 1; rect.y = 1;
rect.h = mesurface->h;
rect.w = mesurface->w;
bool quit = false;
while (quit == false) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
quit = true; }
SDL_RenderClear(rend);
void aaBS(); printf("1");
SDL_RenderCopy(rend, me, NULL, &rect); } SDL_Delay(5);
SDL_RenderPresent(rend); } SDL_DestroyWindow(window);
SDL_Quit; return 0;}
void aaBS() {
if (rect.x >= 780 || rect.x < 0) {
a = a * (-1); }
else if (rect.y >= 580 || rect.y < 0) {
b = b * (-1); }
rect.x = rect.x + a; rect.y = rect.y + b; printf("2");}