void moveball(void) { ball1.old_xcenter = ball1.new_xcenter; ball1.old_ycenter = ball1.new_ycenter; ball1.new_xcenter = ball1.new_xcenter + ball1.speedx; ball1.new_ycenter = ball1.new_ycenter + ball1.speedy; clear_ball(ball1.old_xcenter, ball1.old_ycenter, ball1.radius); paint_ball(ball1.new_xcenter, ball1.new_ycenter, ball1.radius); }
void main_app_loop() { if (current_screen == SCREEN_GAMEPLAY) { time_now_ms = pulse_get_millis(); if (time_now_ms - time_last_box_drawn_ms >= game_speed) { score++; move_surfaces(); int this_height = ball_y; ceiling = false; if (jump_ticks > 0) { clear_ball(ball_x, ball_y); if (ball_y-15 >=2) { ball_y = ball_y - 2; jump_ticks--; } else { jump_ticks--; ceiling = true; } } else if (ball_y < SCREEN_HEIGHT-112) { if ((ball_y+1 < SCREEN_HEIGHT-112) || ((surface_start_x[6]-4 > 20) || (surface_length_x[6]+surface_start_x[6] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-96) { if ((ball_y+1 < SCREEN_HEIGHT-96) || ((surface_start_x[5]-4 > 20) || (surface_length_x[5]+surface_start_x[5] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-80) { if ((ball_y+1 < SCREEN_HEIGHT-80) || ((surface_start_x[4]-4 > 20) || (surface_length_x[4]+surface_start_x[4] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-64) { if ((ball_y+1 < SCREEN_HEIGHT-64) || ((surface_start_x[3]-4 > 20) || (surface_length_x[3]+surface_start_x[3] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-48) { if ((ball_y+1 < SCREEN_HEIGHT-48) || ((surface_start_x[2]-4 > 20) || (surface_length_x[2]+surface_start_x[2] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-32) { if ((ball_y+1 < SCREEN_HEIGHT-32) || ((surface_start_x[1]-4 > 20) || (surface_length_x[1]+surface_start_x[1] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else if (ball_y < SCREEN_HEIGHT-16) { if ((ball_y+1 < SCREEN_HEIGHT-16) || ((surface_start_x[0]-4 > 20) || (surface_length_x[0]+surface_start_x[0] < 20))) { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } } else { clear_ball(ball_x, ball_y); ball_y = ball_y + 2; } draw_ball(ball_x, ball_y, green); if ((this_height == ball_y) && (!ceiling)) { jumps_available = 2; } if (ball_y >= SCREEN_HEIGHT-1) { game_over(); } time_last_box_drawn_ms = time_now_ms; } else if (current_screen == SCREEN_CLOCK) { pulse_get_time_date(¤t_time); } } }