1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
//Drawing the map looks like this
if(Redraw && al_is_event_queue_empty(EventQueue) || ForceRedraw)
{
Redraw = false;
ForceRedraw = false;
for(int Drawx = 0; Drawx < MapX; Drawx++)
{
for(int Drawy = 0; Drawy < MapY; Drawy++)
{
al_set_target_backbuffer(GameDisplay);
al_draw_bitmap_region(TileSheet, Map[Drawy][Drawx] * TileSize, 0, TileSize, 32, Drawx * TileSize,
Drawy * TileSize, 0);
}
}
for(int Drawx = 0; Drawx < MapX; Drawx++)
{
for(int Drawy = 0; Drawy < MapY; Drawy++)
{
al_convert_mask_to_alpha(PlayerTileSheet, al_map_rgb(255, 0, 255));
al_draw_bitmap_region(PlayerTileSheet, PlayerMap[Drawy][Drawx] * TileSize, 0, TileSize, 32, Drawx * TileSize,
Drawy * TileSize, 0);
}
}
}
//movement looks like this
if(Event.type == ALLEGRO_EVENT_KEY_DOWN)
{
switch(Event.keyboard.keycode)
{
case ALLEGRO_KEY_UP:
Y2 = Y - 1;
if(PlayerMap[Y2][X] == 5)
{
PlayerMap[Y][X] = 5;
Y--;
PlayerMap[Y][X] = 0;
ForceRedraw = true;
}
break;
|