This newer version makes the balls an object and then creates a list that it works with to update and display objects. I could easily bound dozens of balls around using this program. I also check return values and quit if I manage to not load any balls.
multiballbounce.c
https://github.com/BuckRogers1965/SDLtut/blob/master/ball.bmp
https://github.com/BuckRogers1965/SDLtut/blob/master/BigBlueBall.bmp
Download the two ball images and the .c file to the same directory.
Compile the program using
gcc `sdl-config --cflags --libs` multiballbounce.c
This is much changed from the original file here. While I was working on this program I needed to find out what data the SDL_Surface pointer gave you access to after you loaded an image. I found this site which has detailed info on all the SDL function calls and data structures. Next up is a little collision detection between sprites. After that I want to work on some physics so that gravity shows it's hand.
No comments:
Post a Comment