PDA

View Full Version : RPG Game how to?



Chesso
27-01-2005, 12:48 PM
Well my subject wasn't very specific but i couldn't think of anything appropriate. Anyway right now im using D7 with UnDelphiX and want to make or atleast start a little rpg game.

It'll be just using 32x32 Square tiles and i want to find out how i can have my own little map files and load/draw them. Im using DxDraw component(obviously), DXImageList for storing gfx and DXTimer for updating the screen. What im really looking for is maybe a tutorial or something on doing this you know the whole tiling and map thing.

Im not really a begginner been using delphi for a couple of years but don't know all that much about game programming and using UnDelphiX(DelphiX).

P.S Funny thing here this is the forum ive been trying to find for days now for my UnDelphiX installation topic as i needed to re-install it again. Someone pointed me in this direction from delphipages for help with my little problem i didnt realise this was the place i was looking for until i tryed to sign up and it said my username and email had already been used and found my topic through searching :D

Wow ok i think i have rambled on enough.

K4Z
25-02-2005, 04:33 PM
Creating a map, and map format can be complex, depending on how advanced you want it, since, the player will be looking at the map screen more than most other screen in the game.
Without writing 20 pages worth of code and tutorial, here's and extremely basic and stripped down way I've used in my RPGs (no events, no npcs, no monsters, etc)

well umm, to start you need a structure, something like:

type
TMap = record
Tiles : array[0..39],[0..39] of byte;
end;

var
Map : TMapdata; //use for the map
MapFile : file of TMapData;//use to save/load the file

----
You need to create a tileset, with a maximum of 255 tiles.
You will also need to make map a program (a Map Maker), that will easily let you populate the Map with numbers to tiles.
---
There are two ways of drawing the map to screen, the slow-less memory using way, or faster-more memory consuming way. I prefer using a bit of memory to make the game go faster so thats what I'll try to explain.
When you load the map, you need to loop through map array and copy tile by tile, using the number in the array as an offset to the tile, to an offscreen bitmap (preferable an offscreen DxDrawSurface).
So, the map will be drawn to and stored as one big picture to an offscreen surface. Then you just copy, or draw from the offscreen surface to the main Dxdraw surface, then draw your sprite, and flip.

Ok, that's a very simple and rather vague example. But if anyone would like more explanation, I'd be happy to go into more detail and provide some actually working code.