Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- // Outbreak - MAP DRAWING LIBRARY //
- // Version 0.1 - 10/13/2011 //
- // Created by: Julien 'Timscampi' Machiels //
- // Under GPL v3 licence //
- ////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- //// Refreshes the map each frame //////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- procedure frame(x,y,xmax,ymax,color : byte);
- var tracex, tracey : byte;
- begin
- // Top map border
- textcolor(color);
- gotoxy(x,y);
- write(chr(201));
- for tracex := x+1 to xmax do
- begin
- gotoxy(tracex,y);
- write(chr(205));
- end;
- gotoxy(xmax+1,y);
- write(chr(187));
- // Bottom map border
- gotoxy(x,ymax+1);
- write(chr(200));
- for tracex := x+1 to xmax do
- begin
- gotoxy(tracex,ymax+1);
- write(chr(205));
- end;
- gotoxy(xmax+1,ymax+1);
- write(chr(188));
- // Left map border
- for tracey := y+1 to ymax do
- begin
- gotoxy(x,tracey);
- write(chr(186));
- end;
- // Left map border
- for tracey := y+1 to ymax do
- begin
- gotoxy(xmax+1,tracey);
- write(chr(186));
- end;
- end;
- procedure drawmap;
- var y,x,map_x, map_y : integer;
- begin
- clrscr;
- map_x := 0;
- map_y := 0;
- frame(map_padx,map_pady,map_padx+map_width,map_pady+map_height,3);
- // Map drawing
- // FIX: drawing gliches
- // TODO: limit drawing to actual map
- for y := (nPlayerY - (map_height div 2)) to (nPlayerY + (map_height div 2)) do
- begin
- for x := (nPlayerX - (map_width div 2)) to (nPlayerX + (map_width div 2)) do
- begin
- gotoxy(map_padx+map_x+1,map_pady+map_y+1); // FIX: Nasty alignement hack
- if ((x < 1) or (x >= mapx+1)) or ((y < 1) or (y >= mapy+1)) then
- begin
- nType := 4; // Void
- end
- else
- begin
- nType := map[y,x]+1; // FIX: Nasty tile_tb hack
- end;
- textcolor(tile_db[nType].txtcol);
- textbackground(tile_db[nType].bkgcol);
- write(chr(tile_db[nType].txt));
- textcolor(15);
- textbackground(0);
- inc(map_x);
- end;
- map_x := 0;
- inc(map_y);
- end;
- end;
- ////////////////////////////////////////////////////////////////////////////////
- //// Refreshes the player each frame ///////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- // TODO: make the player free to move when the screen hits the map's border
- procedure drawchar;
- begin
- textcolor(14);
- gotoxy(19,12);
- write('@');
- end;
- ////////////////////////////////////////////////////////////////////////////////
- //// Checks if the next movement is possible ///////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- function isPassable(x, y : integer) : boolean;
- begin
- // Check if the player is inside the map
- if ((x< 1) or (x >= mapx+1)) or ((y < 2) or (y >= mapy+2)) then
- begin
- isPassable := FALSE;
- end
- else
- begin
- nType := map[y-1,x];
- isPassable := not tile_db[nType].passable;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement