Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #include <avr/io.h>
- #include <util/delay.h>
- #include <graphics.h>
- #include "cpu_speed.h"
- #include "friendly_ports.h"
- #include "sprite.h"
- #include "graphics.h"
- #include "hero.h"
- void update_hero( Sprite * hero );
- void play_hero(void){
- byte bitmap1[] = {
- BYTE( 10100000 ),
- BYTE( 11100000 ),
- BYTE( 10100000 ),
- BYTE( 00000000 ),
- BYTE( 00000000 ),
- BYTE( 00000000 ),
- BYTE( 00000000 ),
- BYTE( 00000000 )
- };
- Sprite hero;
- init_sprite( &hero, 40, 23, 3, 3, bitmap1 );
- hero.is_visible = 1;
- //srandom( 5198985 );
- //double angle = ((double)random()) * 2 * M_PI / RANDOM_MAX;
- hero.dx = 1;
- hero.dy = 0;
- //while(1){
- update_hero ( &hero);
- draw_sprite( &hero);
- refresh();
- // move forward 1 pixel until hit walls
- }
- /* void turn_hero (Sprite * hero, double degrees){
- double angle = degrees * 3.1416 / 180;
- double c = cos (angle);
- double s = sin (angle);
- float newdx = c * hero->dx - s * hero->dy;
- float newdy = s * hero->dx + c * hero->dy;
- hero->dx = round(newdx);
- hero->dy = round(newdy);
- } */
- void update_hero( Sprite * hero ) {
- hero->x += hero->dx;
- hero->y += hero->dy;
- if ( hero->x >= LCD_X - hero->width || hero->x < 40 ) {
- hero->dx = -hero->dx;
- }
- if ( hero->y >= LCD_Y - hero->height || hero->y < 0 ) {
- hero->dy = -hero->dy;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement