Skip to main content
gamedev.net
🔒 Locked

-# SDL_Rect problem

Started by raptorstrike Nov 5, 2004 at 5:21 PM 11 replies 1.5k views
Original Post
raptorstrike
raptorstrike
clearly SDL_Rects dont go below zero but i need somthing to go off the screen on the - x axis so how would i do this? thanks
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
C-Junkie
C-Junkie
They do to.

they look like this:

int x,y;
unsigned int w,h;
raptorstrike
raptorstrike
well whenever i try to increment the number under 0 there must be a error catch or somthing because logic (and what i know about ints) tells me that it should either go into a -# or loop back to the highest posible digit for that preticular byte but its not so there must be somthing stoping it i have the following code

V_Enemys->R_Enemy.x -= V_Enemys->Speed;

and this code is being looped at about 30 FPS (i think) but when the picture reaches the far left hand side (the place were X = 0 it just stops. obviously the numbers arnt changing and neither is my equation so it must have to do with the Rect class
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
C-Junkie
C-Junkie
It could be the SDL_BlitSurface function adjusting the numbers to reflect the clipping it did when it rendered the surface.
raptorstrike
raptorstrike
ok so how would i change that? is there a way to modify cliping?
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
AfroFire
AfroFire
SDL_Rect looks like this -

typedef struct {	Sint16 x, y;	Uint16 w, h;} SDL_Rect;


Awhile ago I never had this problem, perhaps they changed something because now I am having it as well.

AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
raptorstrike
raptorstrike
maybe it has if it has can i\should i modify the rect or would that through the entire system out of wack and if so under witch file .cpp or .h can i find the struct
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
Feidias
Feidias
Quote:
Original post by raptorstrike
ok so how would i change that? is there a way to modify cliping?


SDL_SetClipRect?
raptorstrike
raptorstrike
so when im trying to get the Image to scope out smoothly i can just modify the srect (optional framentation blitting) so that the image is appering to go out of scope?

right now i have this
if(V_Enemys->sRect.x == 0)               {                   V_Enemys->sRect.w = I_Enemy->w;                   V_Enemys->sRect.h = I_Enemy->h;               };                   SDL_BlitSurface(I_Enemy,&V_Enemys->sRect,screen,&V_Enemys->R_Enemy);               V_Enemys->sRect.x = V_Enemys->R_Enemy.x;               V_Enemys->sRect.y = V_Enemys->R_Enemy.y;               V_Enemys->sRect.w--;

to me it looks right but it dosnt work the image just stops at 0 still and the optional blitting dosnt take place at all
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
raptorstrike
raptorstrike
i do pass a reference shouldnt that do the job or do i need to creat a whole seperate parallel (= the same thing) rect
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
raptorstrike
raptorstrike
yey it works now i made a function like so

void TempRectBlit(SDL_Surface* src,SDL_Surface* dst,SDL_Rect Parent_Rect){    SDL_Rect TempRect = Parent_Rect;    SDL_SetColorKey(src, SDL_SRCCOLORKEY, SDL_MapRGB(src->format, 0, 0,0) );    SDL_BlitSurface(src,NULL,dst,&TempRect);};  

pretty much a blit function with some extras (like pre-established alpha black and the temp rect) and it work really well so i think ill use this from now on for bliting thanks for the help guys

[smile]
____"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.