Results 1 to 15 of 15

Thread: 2D Tile game - tips?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16

    Resolved 2D Tile game - tips?

    Anyone have any links/info on what needs to be done to setup the tiles in a form? How to setup an array for this, how to actually get the tiles placed in a form, code to change the tiles, etc.

    Any information would be good. :-)
    Last edited by AcidOsmosis; Oct 13th, 2004 at 06:33 PM.

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Is this directX or plain vb?

    What design have you considered? So we wont barrage you with different ways of skinning the cat.

  3. #3
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    VB Code:
    1. Dim World(50,50) as string

    an two dimensioned array will define the world each element represents a tile


    to create a loadable level with varying widths and heights. First you need a file to define the level. then use an array like this

    VB Code:
    1. Private World() as string
    2.  
    3. sub main()
    4.     redim world([World Width],[World Height])
    5. end sub




    To display the tiles you need to work out what graphics you will be using? DX etc
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16
    I wont be using DirectX, because I don't know enough about what I am doing. :-P Just plain old picture boxes or something like that. Not really sure. Thats one thing I need to figure out :-)

  5. #5
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Let's talk just graphics for the time being..

    We'll the common practice, either directX or something else, would be to create a tileset, eg set of pics for items, set of pics for terrain. You'll need to then define the dimension of each tile in the set, eg 10x10 pixels so a tileset pic 100 x 100 pixels will have a max of 100 tiles in it.

    So what you store in a text file or a database is the position coordinate of a given tile. Say for the first tile in the map you'll need pic 4,5 from the terrain tileset which will be at pixel 40, 50 since each tile is 10x10 pixels. You can also decrease computations by storing the pixel coordinates intead of position coordinates, up to you.

    To get the particular tile from the surface(directX) or tileset you'll neet to BitBlt in order to copy only the pic at the coordinates specified so you'll return a 10x10 tile from the tileset with the function.

    I STRONGLY suggest you get a graphics artist so you can focus on the coding and design. Just tell him the images you need and their sizes. eg Make me pics of a character 10x10 pixels facing front, back, right, left, make the background transparent and put them together in a bitmap 10x40.

    As to the tilesets you need, think of it in terms of layers. Background, mid layer, forground for additional details. Background tiles don't have to worry about transparency, the upper layers have to take that into consideration.

    Thats it for now. We'll worry about creating the screen display from the extracted tiles later on.
    Last edited by leinad31; Oct 13th, 2004 at 09:48 AM.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16
    Well I'm just concentrating on the coding right now. I am a graphic artist myself (also went to college for computer animation), and I will probably do most of the graphics but as I said this is just for my learning experience and 99.9% most likely will never be played by anyone but me or looked at by a few friends.

    As for the graphics though. What I will do: If say each tile is 16x16 then I will just create "dummy" tiles. For example, the character I will just create a tile with the word "char" on it. For creatures I'll create tiles "1" "2" "3" etc for creature #1,#2,#3 etc. That way I can concentrate on coding and one of the last steps will be to actually create real graphics and/or maybe walking animations of some type/etc.

    Right now I just need ideas on how to go about the coding of tiles, how to setup the tiles, how to place each tile for each map, how to place the players icon where it needs to be when he/she starts a map, moves forward/back/left/right/etc.

    I'm also making a habit of creating procedures in modules for any code that might be used again (such as one procedure I created which updates a box that displays the players stats - all I have to do is call that sub procedure in the module to update that).

  7. #7
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    The codes I have are for directX... sorry.

    Try a search on BitBlt or BltBit

  8. #8
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    Sample type, you wont need all characteristics I think, my friend didn't use all of them. He got the definition from elsewhere..

    VB Code:
    1. Option Explicit
    2.  
    3. Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
    4.  
    5. 'Global constants
    6. Global Const SCREEN_WIDTH = 640
    7. Global Const SCREEN_HEIGHT = 480
    8. Global Const SCREEN_BITDEPTH = 16
    9. Global Const TILE_WIDTH = 32
    10. Global Const TILE_HEIGHT = 32
    11. Global Const TILESET_COLUMNS = 19
    12. Global Const TILESET_ROWS = 14
    13. Global Const SPEECH_WIDTH = 640       'for speech box
    14. Global Const SPEECH_HEIGHT = 120      
    15. Global Const SPEECH_START_HEIGHT = 20
    16. Global Const SPEECH_START_WIDTH = 25
    17. Global Const SPEECH_LINE_SPACING = 20
    18.  
    19. Global Const FACE_DOWN = 0
    20. Global Const FACE_LEFT = 1
    21. Global Const FACE_UP = 2
    22. Global Const FACE_RIGHT = 3
    23. Global Const FIGHT = 4
    24. Global Const MAGIC = 5
    25.  
    26. Global Const MOVE_DOWN = 0
    27. Global Const MOVE_LEFT = 1
    28. Global Const MOVE_UP = 2
    29. Global Const MOVE_RIGHT = 3
    30. Global Const MOVE_NONE = 4
    31.  
    32. Global Const HORIZ_EDGE = 10
    33. Global Const VERT_EDGE = 7
    34.  
    35. Global Const MAX_FPS = 100
    36. Global Const FADE_DELAY_MS = 5
    37.  
    38. 'Map declarations
    39. Type PORTAL_TYPE
    40.     strMapName As String
    41.     IntX As Integer
    42.     IntY As Integer
    43. End Type
    44. Type MONSTER_TYPE
    45.     bytMonster(3) As Byte
    46.     bytProbability As Integer
    47.     lngProgChange As Long
    48. End Type
    49. Type MAP_TYPE
    50.     intColumn As Byte
    51.     intRow As Byte
    52.     blnNonWalkable As Boolean
    53.     udtPortal As PORTAL_TYPE
    54.     udtMonster As MONSTER_TYPE 'to define starting location of monster
    55. End Type
    56. Global gudtMap() As MAP_TYPE
    57. Global gstrMapName As String * 16
    58. Global gstrMusic As String * 16
    59. Global gstrMusicPlaying As String * 16
    60.  
    61. Public strCurrentMap As String * 16
    62.  
    63. 'Character declarations
    64. Type CHARACTERTYPE
    65.     intXTile As Integer
    66.     intYTile As Integer
    67.     bytFacing As Byte
    68.     bytAnim As Byte
    69.     intAnimDelay As Integer
    70.     intWalkAnimRate As Integer
    71.     intWalkSpeed As Integer
    72.     intHorizontalDisp As Integer
    73.     intVerticalDisp As Integer
    74.     blnMoving As Boolean
    75.     bytHeading As Byte
    76.     bytCharNum As Byte
    77.     bytBehaviour As Byte
    78.     strSpeech As String
    79.     blnSpeaking As Boolean
    80. End Type
    81. Global gudtCharacter() As CHARACTERTYPE 'Working array for characters
    82. Global gintCenter As Integer            'Character array pointer, values > 1 are NPCs
    83.  
    84. 'NPC declarations
    85. Type BEHAVIOUR_TYPE
    86.     lngProgressReq As Long          'Progress required to exhibit this behaviour set
    87.     strText As String               'Speech text
    88.     bytTalkItemChange As Byte       'Item change after talking?
    89.     lngTalkProgChange As Long       'Progress change after talking?
    90.     blnDisapear As Boolean          'Disappear after talking?
    91.     bytBehaviour As Byte            'Walking behaviour
    92.     bytCharNum As Byte              'Sprite to display
    93.     bytMonster As Byte              'Monster to fight after speech
    94.     blnVisible As Boolean           'Is the sprite visible at this time?
    95.     IntX As Integer                 'Starting coords of the sprite
    96.     IntY As Integer
    97. End Type
    98. Type NPC_TYPE
    99.     udtBehaviour() As BEHAVIOUR_TYPE
    100. End Type
    101. Global gudtNPC() As NPC_TYPE        'Holds character info read from map.
    102. Global glngProgress As Long
    103.  
    104. 'Other variables
    105. Public blnRunning As Boolean

  9. #9
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Hmm a graphics designer you say...



    Are you haveing a scrolling map at all?
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Oct 2004
    Posts
    16
    No, I'm keeping it simple for now. I only have two weeks of self-taught programming experience.

  11. #11
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Oh i see.

    See attached.

    It will show the basics of file handling and how to tile.
    Attached Files Attached Files
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  12. #12
    New Member
    Join Date
    Dec 2008
    Posts
    3

    Re: 2D Tile game - tips?

    4 years laters... lol

    So in conclusion, Directx is usefull for graphic programming ?
    Like in this example. We try to draw different tile at different location.

    If what I said is correct, did I need to learn the basics of file handing before learning Directx?
    And have you an other basics tile example for vb.net? (How to draw a tile in a picturebox)

    Thanks you! and sorry for my english I am french!

  13. #13
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: 2D Tile game - tips?

    DirectX apis are for game- and multimedia programming and 3d engineering jobs.
    http://en.wikipedia.org/wiki/DirectX
    Read this intro.

    GDI is designed for graphics. Just like the Windows GUI, and photo editor programs. However, you can use GDI api calls, for simple (not 3d) gaming purposes. There is a quite advanced API tree for all imaging jobs.

    did I need to learn the basics of file handing before learning Directx?
    Game programming is an advanced level of programming. Mostly. That means, you have to use almost every resources of a computer to build up a working game.
    But, for single tic-tac-toe things, you can learn the basics in a day, or two.
    Last edited by Jim Davis; Dec 16th, 2008 at 11:59 PM.

  14. #14
    New Member
    Join Date
    Dec 2008
    Posts
    3

    Re: 2D Tile game - tips?

    Thanks,
    I know the basics of game programming(tic-tac-toe, pong...) and now I want to try to make a rpg game. Is for that I want to do a simple map editor. My question was more "Did I need to learn how to make en map editor without Directx before".
    Maybe I should repost in the .net forum, how to draw a tile in a picturebox(but I will search on internet before ).

    ++

  15. #15
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: 2D Tile game - tips?

    Or you just can post your questions in the Games and Graphics Programming, that is the gaming forum
    http://www.vbforums.com/forumdisplay.php?f=2

    You have to write a concept about your game. Just like, what viewport you wanna implement (topdown/isometric/3d free look), also what technologies you wanna use. What type of character models you wanna use (animated image/3d models). If you find your concept, you will find out what displaying technologies you have to use, to create your map editor.

    I also recommend you to share the technology for both the game and the map editor. So, you can test your map instantly, also your editor will work as a WYSIWYG (what you see is what you get).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width