Click to See Complete Forum and Search --> : Maps
VB Knowadge
Jul 17th, 2000, 12:23 AM
I want to make a simple 2D game engine. All I want it to do is load in a map, convert the character at each place in the map, 1 character with 36 differnt characters possable, into a tile, and have a picture of a player that can be moved around the map but only on some of the tiles. Some tiles may be land while others are water. I also want the map to be larger than one screen. Exmaple: Screen: 50 tiles by 50 tiles Map: 100 tiles by 100 tiles.
How can i do this? And Fox, I have already asked this(name: *Super Sniper*) so please don't give me the link to your download or to that old thread.
For storage purposes, you can load your Map in a 2D-Array. It will save a lot of time.
Dim Map(100, 100) As Byte
Before you move your Character, check the direction he is going in. If it's a wall (1 on the Map, for example) then don't move him.
Fox
Jul 17th, 2000, 11:54 AM
In my game the map() array points to a set of tiles, where the tile defines if you can move there or not. That's also a ways, but if you're new to game programming it maybe hard to understand..?
SteveCRM
Jul 17th, 2000, 09:28 PM
Okay, I've heard everyone talk about making maps in 2D arrays and stuff, but can someone actually show how to do this? Like to I assign a value to each point to say which picture goes where? So if 55,55 = 1 then its grass, but if it = 2 then its water?
Fox
Jul 18th, 2000, 12:22 AM
Yep. Like I said, you have ie. a tile array which really holds the graphics. Like this:
Type TILE
LONG DC;
BOOL Collides;
End type
TILE Tiles(100);
Type MAP
LONG Tile;
End type
MAP Map(10, 10);
So the MAP(x,y) just points to an index in the Tiles() array.
Lepe
Jul 18th, 2000, 12:27 PM
Hi, I'm making a game where I use Maps of 500 x 500 where I only use 9 pieces for each screen like this:
ooooo
oxxxo
oxxxo
oxxxo
ooooo
I load In memory only 25 pieces and I rotating it, depending of where he (the player) moves. I made an Array like this:
Dim World (1 to 500, 1 to 500) as Byte
then I read a Text File and I load it to my Array:
Open ...... as #1
For I = 1 to 500
For J = 1 to 500
....
Input #1, Piece
World (I,J)= val(Piece)
...
...
Piece can be Numbers from 1 to 255 then you can have the pieces loaded in a Sprite and get it from there.
I hope you find this usefull. (sorry my english)
[Edited by Lepe on 07-18-2000 at 01:34 PM]
If you declare many Array's that require 1 as the starting point, you can shorten your code by using Option Base 1. Eg:
Option Base 1
Public World(100, 100) As Byte
Public Weapons(10) As Byte
Public Items(50) As Byte
This saves you from typing (1 To number).[/i]
Jotaf98
Jul 18th, 2000, 01:30 PM
Hey, Fox... that thing you said that might be a bit too complex... I'm interested ;)
Is it like instead of detecting tiles, detecting pixels (like a round obstacle)? That's what I wanted... so every square of terrain would have a "mask" so the game knew what parts of the tile must be considered obstacles!
Bye,
-Jotaf98
jotaf98@hotmail.com - ICQ#60784495 - http://jotaf98.cjb.net
VB Knowadge
Jul 18th, 2000, 02:52 PM
Well, I think I understand how to do it. Now, does anyone fell up to making me a tileset? For now I just need 10 tiles and 1 Character.
Jotaf98
Jul 18th, 2000, 05:35 PM
Hum, it depends -- what do you mean by "tileset"? For me, a tileset is a set of terrain images used in a game (ice, jungle...) -- so the tiles used vary depending on the tileset (so you won't need too many bytes to define a tile in a map). So if what you need is temporary images, I can get ya some :p
Bye,
-Jotaf98
jotaf98@hotmail.com - ICQ#60784495 - http://jotaf98.cjb.net
Sastraxi
Jul 23rd, 2000, 10:59 AM
Fox? ...That looks a little bit like C/C++ mixed with VB and Java. Or is it? Correct me if i'm wrong, but I don't think that'll run in VB....
Fox
Jul 23rd, 2000, 11:52 AM
Indeed :) It's C++ and VB mixed. I didnt want to write [DC as Long] and so on, takes too much time ;)
Sorry about that, but that was not really code, only the idea how it works ;)
slashandburn
Jul 25th, 2000, 02:20 PM
The array I have found to be the best is
MAP(0 to 50,0 to 50,0 to 1) AS INTEGER
The First Part "0 to 50" is the X
The Second Part "0 to 50" is the Y
The Third Part "1" is the Walkable Check
The Third Part "0" is the TILECHECK
Then when the map is loaded make it check the
tile, if it is a block tile then it sets the 3RD
value1 to 1, or 0 if walkable. This may help
a little since it saves everything into an ARRAY.
So an example would be
TILE = map(10,10,0)
BLOCK = MAP(10,10,1)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.