Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / tiles and 2d

Author
Message
CRubbish
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 26th Feb 2004 01:44
i'm fairly new and ive seen many people talk about using tiles.
I'm wondering what thier uses are and if they can be used in 2d.

I saw somthing that was like this...

000000000
100000001
100001001
100001101
100001001
111111111

is this supposed to represent each square on map? or what?
i'd like to figure out how to use tiles if they would be a help to me. thanks to anyone who takes the time to help.

Phil 3:7-11
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 26th Feb 2004 02:15
id it have "data" befor all the numbers because if not then i'd say its probably just binary...but if it had the word "data" just befor all the numbers then it is for the ground and objects as each 0,1,2,3, ect ect represents a place on the 'map' and where to put it.

The search continues.

Current project - A space game
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Feb 2004 02:24
Yeah. Look at the picture that I have posted. Each square is treated as a number. 0,1,2,3 etc. Some tiles can be walked on..usually 0. Others can be collided with. As you walk over the map, the computer just compares where you are standing with a number. If it's > 0 then you have collided with something.




CRubbish
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 26th Feb 2004 05:17
oh ok, so are their any good free editors available that are similar to the one above?

and is the coding difficult to use a map editor?

thanks very much.

Phil 3:7-11
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Feb 2004 10:56 Edited at: 26th Feb 2004 11:04
Coding the collision for tiles should be easy, I learned it by making a Pacman game many years ago in Amos, but I did start off with a tutorial of Pacman in a magazine so that was much easier than working it all out myself. I did improve the code quite a lot in the end though. It works like this.......

Your sprite has X/Y coordinates.....
The screen has pixels....
Your map has tiles...

If your graphics use tiles that are 32 pixels * 32 pixels then..
Your Map of 0's and 1's should match the graphics. So...
Dim Map (Screen Width / 32,Screen Height / 32) or....
Dim Map (Screen Width / Tilesize,Screen Height / Tilesize)

For tile sizes it's best to use a number that divides perfectly into your screen resolution.

Now you need to constantly check your sprite's position from its centre...

spritewidth=(sprite width(1)/2)
spriteheight=(sprite height(1)/2)
offset sprite 1,spritewidth,spriteheight


That sets all of your sprite X/Y coords to be taken from the sprite's centre, rather than it's top left.

Now position your sprite on the screen, so that you know exactly which tile it is standing on, and exactly which pixel of that tile it is standing on.

Now think carefully.....x64,y64 is Map position x2,y2, but half of your sprite is over Map position x1,y1, which means that you may have positioned the sprite half way over a wall, which is not allowed. Perfect positioning would be x64 + (sprite width(1)/2), y64 + (sprite height(1)/2). Now he is standing on a Map position with his left edge against another tile position.

Best for you to start coding now. Too much reading of this just gets confusing. It becomes clear when you start thinking about it for yourself.

Free map editors can be found on the Net. They can be written in any language, even Blitz Basic, because they just save out the 0's and 1's, and other numbers, and they can be read by DB or DBPro. There are some in Visual Basic too, and some being made on here.

Pincho.

CRubbish
20
Years of Service
User Offline
Joined: 11th Feb 2004
Location:
Posted: 27th Feb 2004 01:44
thanks a lot i'll hafta start trying it out and see what i can do.

Phil 3:7-11
GameMaker Jason
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 29th Feb 2004 23:49
@Pincho where can I get the level editor that your screenshot shows?

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 1st Mar 2004 01:07
I just posted that picture as an example. It comes with a game called MineArena, and I don't think that you can load your own tiles into it. There are a lot of map editors out there. Actually it only takes a couple of days to make your own.

GameMaker Jason
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 3rd Mar 2004 19:54
how do you actually put the tiles on the screen in the required position? and update the map data (data statement) to show the new position of the pacman?



ps im makin' pacman

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Mar 2004 22:05
With a screen res of 800 * 600 Pacman moves 32 pixels at a time. The tiles are also 32*32. So he is either going to hit a wall or he isn't. To put the 32*32 tiles on the screen you can use Data, or you could just load a ready made screen. You are going to need Data anyway so it makes hardly any difference. Pacman moves around on tiles. In the real version of Pacman, even the pills were tiles, but nowadays some people use sprites. So each time that you paste a tile on the screen you need to increase the x pos by 32, and when the x pos > 800 you need to make it 0 again, and add 32 to the y pos. There are lots of examples around so take a look.

Cros Jovil
20
Years of Service
User Offline
Joined: 27th Jan 2004
Location:
Posted: 3rd Mar 2004 22:52
can you give an example of a full data sequence for a small map just want to see whta the data should look like
GameMaker Jason
20
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 3rd Mar 2004 23:01
data sequence is

Data 1,1,1,1,1,1,1,1,1,1,1,1,1
Data 1,0,0,0,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,0,0,0,1
Data 1,0,0,1,1,1,0,1,1,1,0,0,1
Data 1,0,0,1,0,0,0,0,0,1,0,0,1
Data 1,0,0,1,0,0,2,0,0,1,0,0,1
Data 1,0,0,1,1,1,1,1,1,1,0,0,1
Data 1,0,0,0,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,0,0,0,1
Data 1,1,1,1,1,1,1,1,1,1,1,1,1

1=wall
0=black floor
2=pacman start

also i'm not to good at movin' the pacman across the tiles with the keys, help there would be useful?

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 3rd Mar 2004 23:16
That map's a bit wrong. Keypresses work like this..

When you press a key, say left, Pacman walks left in a loop. He moves 2 pixels at a time, 16 times in the loop = 32 pixels.

For pacmove = 2 to 32 step 2

In here you move the sprite, adding Pacmove to his sprite position.
You also gosub the keypress routine, and store the keypress. This is often forgotten, and the Pacman does not respond during his move routine.


Next Pacmove

Pincho.

Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 4th Mar 2004 00:14
Try the AgP Map-Editor
http://darkbasic.thegamecreators.com/?m=forum_view&t=26918&b=5



supports a 1200x900 tile map

Quote: "
UPDATED

Amd 2800+ | 1024mb pc3200 | A7N8eluxe | Ati Radeon 9800PRO 256mb
"
UnderLord
20
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 4th Mar 2004 06:51
So for data commands let me get this right as im having one of those what do us american's call it? a clear moment in our heads? yes but anyhow....damn its fading must type fast. So for the data to be placed on as a map with collision does it take from the image numbers?

1 = wall
2 = floor
3 = support beam (for the hell of it)




The search continues.

Current project - A space game
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 4th Mar 2004 10:27
Yes Data can be used that way. Pacman has....

0 = black tile you can walk on.
1 = small power pill on black tile
2 = Large power pill on black tile
3 = wall.....Yellow square
4 = Ghost base tile......purple square

These can all be put into Data, or you can use sprites for some of them. I think that I would stick with the Data for everything.

Login to post a reply

Server time is: 2024-05-18 01:56:38
Your offset time is: 2024-05-18 01:56:38