Fixed the out of bounds issues but the character slides lol
This commit is contained in:
@@ -19,6 +19,8 @@ void ClearButtons();
|
||||
|
||||
void InitTimer();
|
||||
|
||||
void InitAudio();
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+25
-20
@@ -52,6 +52,13 @@ void EINT3_IRQHandler(void){
|
||||
int timer_count = 0;
|
||||
int scroller_divider = 25;
|
||||
int scroll_increment = 1;
|
||||
void increment_scroll(int value){
|
||||
scrolling += value;
|
||||
if(scrolling <= 0)
|
||||
scrolling = 319;
|
||||
if(scrolling >= 320)
|
||||
scrolling = 1;
|
||||
}
|
||||
void SysTick_Handler(){
|
||||
timer_count += 1;
|
||||
//update the screen
|
||||
@@ -62,14 +69,6 @@ void SysTick_Handler(){
|
||||
}
|
||||
}
|
||||
|
||||
void increment_scroll(int value){
|
||||
scrolling += value;
|
||||
if(scrolling <= 0)
|
||||
scrolling = 319;
|
||||
if(scrolling >= 320)
|
||||
scrolling = 1;
|
||||
}
|
||||
|
||||
int number_of_digits (int value){
|
||||
int interVal = value;
|
||||
int count = 0;
|
||||
@@ -110,16 +109,20 @@ Player CreatePlayer(){
|
||||
}
|
||||
|
||||
void RefreshPlayer(Point vector){
|
||||
|
||||
if(player.Hitbox.Position.Y + vector.Y < 0){
|
||||
player.Hitbox.Position.Y = SCREEN_SIZE.Height - (0-vector.Y);
|
||||
}else{
|
||||
if(player.Hitbox.Position.Y + vector.Y >= SCREEN_SIZE.Height){
|
||||
player.Hitbox.Position.Y = vector.Y - (SCREEN_SIZE.Height - player.Hitbox.Position.Y);
|
||||
}else{
|
||||
player.Hitbox.Position.Y += vector.Y;
|
||||
}
|
||||
}
|
||||
|
||||
player.Hitbox.Position.X += vector.X;
|
||||
player.Hitbox.Position.Y += vector.Y;
|
||||
|
||||
if(player.Hitbox.Position.Y < 0)
|
||||
player.Hitbox.Position.Y = SCREEN_SIZE.Height - 1;
|
||||
|
||||
if(player.Hitbox.Position.X + player.Hitbox.Size.Width > SCREEN_SIZE.Width)
|
||||
player.Hitbox.Position.X = SCREEN_SIZE.Width - player.Hitbox.Size.Width;
|
||||
if(player.Hitbox.Position.X + player.Hitbox.Size.Width >= SCREEN_SIZE.Width)
|
||||
player.Hitbox.Position.X = SCREEN_SIZE.Width - player.Hitbox.Size.Width -1;
|
||||
if(player.Hitbox.Position.X < 0)
|
||||
player.Hitbox.Position.X = 0;
|
||||
|
||||
@@ -143,10 +146,11 @@ int main(void) {
|
||||
Resize_Window(SCREEN);
|
||||
Draw_stars();
|
||||
|
||||
Point vec = {0,0};
|
||||
int increment = 5;
|
||||
|
||||
while (true)
|
||||
{
|
||||
Point vec = {0,0};
|
||||
int increment = 1;
|
||||
int JoystickState = JoystickGetState();
|
||||
|
||||
if(JoystickState & (1 << 4)){
|
||||
@@ -164,9 +168,8 @@ int main(void) {
|
||||
|
||||
if(need_to_scroll){
|
||||
scroll(scrolling);
|
||||
need_to_scroll = false;
|
||||
|
||||
vec.Y -= 1;
|
||||
need_to_scroll = false;
|
||||
|
||||
int digits = number_of_digits(scrolling);
|
||||
char newStr[digits+1];
|
||||
@@ -179,8 +182,10 @@ int main(void) {
|
||||
DrawText(new_origin,newStr,charSize);
|
||||
}
|
||||
|
||||
if(need_to_scroll || vec.X != 0 || vec.Y != 0)
|
||||
if(vec.X != 0 || vec.Y != 0){
|
||||
RefreshPlayer(vec);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user