🔒 Locked
-# SDL_Rect problem
Advertisement
Original Post
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
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
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
ok so how would i change that? is there a way to modify cliping?
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
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
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
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
i do pass a reference shouldnt that do the job or do i need to creat a whole seperate parallel (= the same thing) rect
yey it works now i made a function like so
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]
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]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement