#include <stdio.h>
#include <allegro.h>
#include <stdlib.h>

#include "car.h"

#define GFX_W 642
#define GFX_H 450



void moveup (BACKG *b, CAR *c, BITMAP *buffer, BITMAP * image)
{
 b->backg_x-=3;
  b->backgc_x-=3;
c->y-=1;
clear_bitmap(buffer) ;

draw_sprite (buffer,b->backgroundprincipale,b->backg_x,b->backg_y) ;
blit (c->car,image,0,0,0,0,260,290) ;
draw_sprite (buffer,image,c->x,c->y) ;
blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
}

void movedown (BACKG *b, CAR *c, BITMAP *buffer, BITMAP * image)
{
 b->backg_x-=3;
  b->backgc_x-=3;
c->y+=1;
rest(0) ;
clear_bitmap(buffer) ;


draw_sprite (buffer,b->backgroundprincipale,b->backg_x,b->backg_y) ;
blit (c->car,image,0,0,0,0,260,290) ;
draw_sprite (buffer,image,c->x,c->y) ;
blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
}

void moveright (BACKG *b, CAR *c, BITMAP *buffer, BITMAP * image)
{
 b->backg_x-=3;
  b->backgc_x-=3;
c->x+=2;
rest(0) ;
clear_bitmap(buffer) ;


draw_sprite (buffer,b->backgroundprincipale,b->backg_x,b->backg_y) ;
blit (c->car,image,0,0,0,0,260,290) ;
draw_sprite (buffer,image,c->x,c->y) ;
blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
}

void moveleft (BACKG *b, CAR *c, BITMAP *buffer, BITMAP * image)
{
 b->backg_x-=3;
  b->backgc_x-=3;
c->x-=2;
rest(0) ;
clear_bitmap(buffer) ;


draw_sprite (buffer,b->backgroundprincipale,b->backg_x,b->backg_y) ;
blit (c->car,image,0,0,0,0,260,290) ;
draw_sprite (buffer,image,c->x,c->y) ;
blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
}
