All pastes #904149 Raw Edit

tonkkis

public cpp v1 · immutable
·published 2008-02-14 19:19 UTC
rendered paste body
#include<iostream>#include<SDL/SDL.h>class Sprite{	private:		SDL_Surface *sprit;		SDL_Rect alue;		int pos_x, pos_y;		SDL_Surface *parent;	public:		Sprite(int,int);		void Create(int,int,SDL_Surface*,Uint32);		void Move(int,int);};Sprite::Sprite(int coord_x,int coord_y){	pos_x = coord_x;	pos_y = coord_y;}void Sprite::Create(int width, int height,SDL_Surface* p,Uint32 color){	parent = p;	alue.x = pos_x;	alue.y = pos_y;	sprit = SDL_CreateRGBSurface(SDL_SWSURFACE,width,height, 32,		parent->format->Rmask,		parent->format->Gmask,		parent->format->Bmask,		parent->format->Amask);	SDL_FillRect(sprit,NULL,color);	SDL_BlitSurface(sprit,NULL,parent,&alue);	}void Sprite::Move(int x_plus,int y_plus){	alue.x+=x_plus;	alue.y+=y_plus;	SDL_BlitSurface(sprit,NULL,parent,&alue);}int main(int *argc, char *argv[]){	Sprite pallo(10,10);	SDL_Surface *naytto;	naytto = SDL_SetVideoMode(800,600,32,SDL_HWSURFACE);	pallo.Create(10,10,naytto,0xff0000);	for(int i = 0;i<100;i++){		SDL_FillRect(naytto,NULL,0x000000);		pallo.Move(1,1);		SDL_Flip(naytto);	}	SDL_Flip(naytto);	SDL_Delay(1000);	SDL_Quit();	return 0;}