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. :-)
Printable View
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. :-)
Is this directX or plain vb?
What design have you considered? So we wont barrage you with different ways of skinning the cat.
VB Code:
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:
Private World() as string sub main() redim world([World Width],[World Height]) end sub
:)
To display the tiles you need to work out what graphics you will be using? DX etc
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 :-)
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.
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).
The codes I have are for directX... sorry.
Try a search on BitBlt or BltBit ;)
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:
Option Explicit Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long 'Global constants Global Const SCREEN_WIDTH = 640 Global Const SCREEN_HEIGHT = 480 Global Const SCREEN_BITDEPTH = 16 Global Const TILE_WIDTH = 32 Global Const TILE_HEIGHT = 32 Global Const TILESET_COLUMNS = 19 Global Const TILESET_ROWS = 14 Global Const SPEECH_WIDTH = 640 'for speech box Global Const SPEECH_HEIGHT = 120 Global Const SPEECH_START_HEIGHT = 20 Global Const SPEECH_START_WIDTH = 25 Global Const SPEECH_LINE_SPACING = 20 Global Const FACE_DOWN = 0 Global Const FACE_LEFT = 1 Global Const FACE_UP = 2 Global Const FACE_RIGHT = 3 Global Const FIGHT = 4 Global Const MAGIC = 5 Global Const MOVE_DOWN = 0 Global Const MOVE_LEFT = 1 Global Const MOVE_UP = 2 Global Const MOVE_RIGHT = 3 Global Const MOVE_NONE = 4 Global Const HORIZ_EDGE = 10 Global Const VERT_EDGE = 7 Global Const MAX_FPS = 100 Global Const FADE_DELAY_MS = 5 'Map declarations Type PORTAL_TYPE strMapName As String IntX As Integer IntY As Integer End Type Type MONSTER_TYPE bytMonster(3) As Byte bytProbability As Integer lngProgChange As Long End Type Type MAP_TYPE intColumn As Byte intRow As Byte blnNonWalkable As Boolean udtPortal As PORTAL_TYPE udtMonster As MONSTER_TYPE 'to define starting location of monster End Type Global gudtMap() As MAP_TYPE Global gstrMapName As String * 16 Global gstrMusic As String * 16 Global gstrMusicPlaying As String * 16 Public strCurrentMap As String * 16 'Character declarations Type CHARACTERTYPE intXTile As Integer intYTile As Integer bytFacing As Byte bytAnim As Byte intAnimDelay As Integer intWalkAnimRate As Integer intWalkSpeed As Integer intHorizontalDisp As Integer intVerticalDisp As Integer blnMoving As Boolean bytHeading As Byte bytCharNum As Byte bytBehaviour As Byte strSpeech As String blnSpeaking As Boolean End Type Global gudtCharacter() As CHARACTERTYPE 'Working array for characters Global gintCenter As Integer 'Character array pointer, values > 1 are NPCs 'NPC declarations Type BEHAVIOUR_TYPE lngProgressReq As Long 'Progress required to exhibit this behaviour set strText As String 'Speech text bytTalkItemChange As Byte 'Item change after talking? lngTalkProgChange As Long 'Progress change after talking? blnDisapear As Boolean 'Disappear after talking? bytBehaviour As Byte 'Walking behaviour bytCharNum As Byte 'Sprite to display bytMonster As Byte 'Monster to fight after speech blnVisible As Boolean 'Is the sprite visible at this time? IntX As Integer 'Starting coords of the sprite IntY As Integer End Type Type NPC_TYPE udtBehaviour() As BEHAVIOUR_TYPE End Type Global gudtNPC() As NPC_TYPE 'Holds character info read from map. Global glngProgress As Long 'Other variables Public blnRunning As Boolean
Hmm a graphics designer you say... :D
Are you haveing a scrolling map at all? :)
No, I'm keeping it simple for now. I only have two weeks of self-taught programming experience.
Oh i see.
See attached.
It will show the basics of file handling and how to tile. :)
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!
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.
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.Quote:
did I need to learn the basics of file handing before learning Directx?
But, for single tic-tac-toe things, you can learn the basics in a day, or two.
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 :) ).
++
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).