Projekt/snake_main.c
void render_frame() {
  /*helper function to reset the isr via bit manipulation*/
  void reset_isr(){
    IFS(0) = IFS(0) ^ 0b0000000100000000; //set bit 8 to 0
  }
  /*"renders" the snake - sends it to the frame buffer*/
  void render_snake(){
    int i;
    //send the snake to the buffer - render snake
    for(i = 0; i<snake.num_blocks; i++){
      //iterates over each block in the snake
      Block pointed_block = snake.blocks_array[i];
      add_square(pointed_block.x0, pointed_block.y0, BLOCK_SIZE);
    }
  }
  /*"renders" the snake - sends it to the frame buffer*/
  void render_apple(){
    //send the apple to the buffer
    add_square(apple.x0,apple.y0,BLOCK_SIZE); //write the apple
  }

  
  set_all_pixels_black();  
  
  
  move_snake();
  check_collision();
  
 
  render_snake();
  render_apple();
  

  
  
  display_buffer();
  
  reset_isr();

}
/*Render a new frame - called when timer ticks over*/
Render a new frame - called when timer ticks over
Render a new frame - called when timer ticks over
void render_frame() {
  void reset_isr(){
    IFS(0) = IFS(0) ^ 0b0000000100000000; 
  }
  void render_snake(){
    int i;
    for(i = 0; i<snake.num_blocks; i++){
      Block pointed_block = snake.blocks_array[i];
      add_square(pointed_block.x0, pointed_block.y0, BLOCK_SIZE);
    }
  }
  void render_apple(){
    add_square(apple.x0,apple.y0,BLOCK_SIZE); 
  }
  set_all_pixels_black();  
  move_snake();
  check_collision();
  render_snake();
  render_apple();
  display_buffer();
  reset_isr();
}
void render_frame ( ) { void reset_isr ( ) { IFS ( 0 ) = IFS ( 0 ) ^ 0b0000000100000000 ; } void render_snake ( ) { int i ; for ( i = 0 ; i < snake . num_blocks ; i ++ ) { Block pointed_block = snake . blocks_array [ i ] ; add_square ( pointed_block . x0 , pointed_block . y0 , BLOCK_SIZE ) ; } } void render_apple ( ) { add_square ( apple . x0 , apple . y0 , BLOCK_SIZE ) ; } set_all_pixels_black ( ) ; move_snake ( ) ; check_collision ( ) ; render_snake ( ) ; render_apple ( ) ; display_buffer ( ) ; reset_isr ( ) ; }
Render a new frame - called when timer ticks over
Render a new frame - called when timer ticks over
/*helper function to reset the isr via bit manipulation*/ //set bit 8 to 0 /*"renders" the snake - sends it to the frame buffer*/ //send the snake to the buffer - render snake //iterates over each block in the snake /*"renders" the snake - sends it to the frame buffer*/ //send the apple to the buffer //write the apple