[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

how can i write a game like this...

it is a top-view game. The map include
blocks(be able to walk through/ not able) and characters.

i want the character whom is under control walks to anyplace i need, and he avoids the blocks that unable to walk through, reachs the goal.

thank you
0
RkMk
Asked:
RkMk
  • 3
1 Solution
 
My name is MudSystems EngineerCommented:
Hmmm... like a labyrinth or so...

Is quite simple, first made a TEXT MAP, like for example a "*" character will be a wall, "#" will be grass, "@" will be a tree, etc... and divide the screen view [graphics mode] in pieces, like 16x16 pixels or 64x64, draw them [the grass, trees and walls, etc make them with paint brush or something] then do a scan of your TEXT MAP, if the first character is a "*" wall, then Draw the wall in a box 16x16 or 64x64, then scan again the TEXT MAP, if you encounter a "*" wall again then draw the wall in distance 64pixels from where you draw the first one, and on and on...

(some thing like this)
*********
*####      *
*##  #  @   *
*    @     *
*********
0
 
My name is MudSystems EngineerCommented:
So once you design the graphic engine, do the Movement engine, with a bunch of rules, like the character in question can't pass thru tree nor wall, but can pass thru grass,

{For UpMovement}
If Key = 'up' Then
  Begin
    If ((Array[X,Y+1] <> "*") and (Array[X,Y+1] <> "@")) Then
      Y:=Y+1
  End;
{For DownMovement}
If Key = 'down' Then
  Begin
    If ((Array[X,Y-1] <> "*") and (Array[X,Y-1] <> "@")) Then
      Y:=Y-1
  End;
{For LeftMovement}
If Key = 'left' Then
  Begin
    If ((Array[X-1,Y] <> "*") and (Array[X-1,Y] <> "@")) Then
      X:=X-1
  End;
{For RightMovement}
If Key = 'right' Then
  Begin
    If ((Array[X+1,Y] <> "*") and (Array[X+1,Y] <> "@")) Then
      X:=X+1
  End;
0
 
My name is MudSystems EngineerCommented:
The Graph engine could be like (if sprites are 16x16)

Type
  ArrayGrp = Array[1..4,1..16,1..16] of Byte;
  ArrayMap = Array[1..16,1..16] of Char;

Procedure ReadSpritesFromFileOrSomething;
Begin
  {Read the sprites from file, or generate them [bad idea]}
End;

Procedure PutSprite(X,Y: Integer; What: Char);
Var
  I,J: Byte;
Begin
  Case What Of
    "*":
       Begin
         For I:=1 to 16 Do
           For J:=1 to 16 Do
             PutPixel(i,j,ArrayGrp[1,i,j])
    "@"
       Begin
         For I:=1 to 16 Do
           For J:=1 to 16 Do
             PutPixel(i,j,ArrayGrp[2,i,j])
    "#"
       Begin
         For I:=1 to 16 Do
           For J:=1 to 16 Do
             PutPixel(i,j,ArrayGrp[3,i,j])
       End;
End;

For i:=1 to 16 Do
  For j:=1 to 16 Do
    PutSprite((i-1)*16, (j-1)*16, Array[i,j]);



And so...

[this was made on the fly, so you'll need much more, well actually not that much]
0
 
HypoCommented:
The first time I made a "from above" game like the one you describe,
I made a map of X*Y bytes... where Each byte in this map pointed into an array of Sprites with fixed bounds: 16*16.
When I was to update the screen, I scanned through the map and put each sprite where the map said it was supposed to be. (similar to whatboys way of doing it)

Anyway: If you want commented examples,
I need your email...
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now