Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This example program is created by thecplusplusuy for demonstration purposes. It's a simple mario like side-scroller game:
- //http://www.youtube.com/user/thecplusplusguy
- //Free source, modify if you want, LGPL licence (I guess), I would be happy, if you would not delete the link
- //so other people can see the tutorial
- //this file is bullet.cpp just a class (implementation) for a bullet.
- #include "bullet.h"
- bullet::bullet(SDL_Surface* img,int x,int y,int xVel,int yVel) //constructor
- {
- //just set all of the variables, nothing new in here
- box.x=x;
- box.y=y;
- image=img;
- box.w=image->w;
- box.h=image->h;
- xvel=xVel;
- yvel=yVel;
- }
- void bullet::move()
- {
- //move the bullet, we just add the velocity (speed) to the position
- box.x+=xvel;
- box.y+=yvel;
- }
- void bullet::show(SDL_Surface* screen)
- {
- //blit it to the screen
- SDL_BlitSurface(image,NULL,screen,&box);
- }
- SDL_Rect* bullet::getRect()
- {
- //return the address of the bound box (for collision detection)
- return &box;
- }
- //that was one of the simplest class, nothing tricky.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement