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.

Author
Message
Chaos
22
Years of Service
User Offline
Joined: 8th Feb 2003
Location: United Kingdom
Posted: 21st Mar 2003 22:32
How do i make a map in 2d that allows my character to move on it but when he hits a tree or something he stops.
It feels as though i have trid everything

Thanx in advance
Darkworlds are all around us just open your eyes
Most of us are still half asleep
Morales
22
Years of Service
User Offline
Joined: 9th Feb 2003
Location: - Please Select -
Posted: 21st Mar 2003 23:13
inc x#

if x# > 30 then x# = 30
Chaos
22
Years of Service
User Offline
Joined: 8th Feb 2003
Location: United Kingdom
Posted: 21st Mar 2003 23:33
i do not understand

Darkworlds are all around us just open your eyes
Most of us are still half asleep
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 21st Mar 2003 23:36
I'd use an array-based grid system. You initialise an array the size of the level, i.e say you divide the level into 100x100 squares, you'd use dim level(100,100). To make a boolean type system to check for objects, you'd use something like dim level(100,100,10), which means that on each square, there could be 10 possibilities, defined by boolean logic, i.e 0=no object on that square, 1=object on that square. Now lets say level(x,y,1) stands for character on square x,y, so if level(x,y,1)=1 then your character inhibits the square, if 0 he doesnt. Then 2 could be an obstacle, i.e if level(x,y,2)=1 theres an obstacle on square x, y. So you could test if you want to move right, if level(characterX+1,characterY,2)=1, i.e the square to the right of the character is occupied by an obstacle, you cant move there. I hope this helps you

Whatever I did I didn't do it!
Andy Igoe
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 21st Mar 2003 23:41
I use a similar system to Kentaree except mine looks more like dim level(100,100) and instead of a true/false state I store an integer to reflect what is there.

Typically I have two arrays, one for what is displayed to screen and one for route-finding.

If for example you have 18 road tiles and 4 grass tiles you dont want to be writting something like: if level(x,y)=1 or level(x,y)=2....

It's faster to hold your map and route finding information in seperate arrays so you end up with

dim displayMap(100,100)
and
dim routeMap(100,100)

so now displayMap() shows what graphic to put onscreen and routeMap() holds a value of 2 for any square that lets you move at say double speed, 1 for movement at normal speed, and 0 for impassable.

so to test if you have hit a tree you would just type if routeMap(x,y)=0 then treeHit=ouch

Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.
Chaos
22
Years of Service
User Offline
Joined: 8th Feb 2003
Location: United Kingdom
Posted: 21st Mar 2003 23:53
isnt there a way i could cause a collision detection bye using the colors of an image ? like if sprite position = green square move
if sprite position = blue square then not move. this would be easier as i have read into this before it is just i dont no how to put it into effect but thanx you guys for your help but can anyone else shed light on the problems???? :-s

Darkworlds are all around us just open your eyes
Most of us are still half asleep
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 22nd Mar 2003 00:17
Well, yeah. You could use the point(x,y) command to get the colour of the pixels at the x,y coordinate, but imho it would be harder, and probably slower than the array system, although it would give better collision, and not square-at-a-time movement but smooth movement.

Whatever I did I didn't do it!
Chaos
22
Years of Service
User Offline
Joined: 8th Feb 2003
Location: United Kingdom
Posted: 23rd Mar 2003 18:05
How would you make it so you know an object is there liek u say if level(x,y,1)=1 how would you know it = to 1. thanx in advance

Darkworlds are all around us just open your eyes
Most of us are still half asleep

Login to post a reply

Server time is: 2025-05-17 16:21:27
Your offset time is: 2025-05-17 16:21:27