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.

DarkBASIC Discussion / 2D Maze Help

Author
Message
Tom Thelwall
19
Years of Service
User Offline
Joined: 5th Oct 2005
Location:
Posted: 12th Oct 2005 22:44
Hi, I needed some help. I want to create a 2d birds eye view maze using no textures. I want to make the character a mouse, basically i need to know how to make it so that the mouse can move around the maze using the directional buttons, but making sure that the mouse collides with a wall of the maze. Can anyone help me, I would be most grateful. Thanks
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 12th Oct 2005 23:10
Here is something:

Inside your Main Loop, put this:

oldy#=sprite y(Player Sprite Number)
oldx#=sprite x(Player Sprite Number)
if upkey()=1 then inc y#,.5
if downkey()=1 then dec y#,.5
if rightkey()=1 then inc x#,.5
if leftkey()=1 then dec x#,.5
y#=sprite y(Player Sprite Number)
x#=sprite x(Player Sprite Number)
if sprite collision(Player Sprite Number,0)
x#=oldx#
y#=oldy#

**Replace all the 'Player Sprite Number' tags with the Sprite number of the mouse.
This will let you move the Sprite, and if you move into any other sprite ( a maze wall ) you will not go through. It will give you an Idea of how to do both.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 12th Oct 2005 23:10
Wait, you know what a Main loop, Sync, and a sprite is right? If not, let me no or you will be stuck!

Login to post a reply

Server time is: 2025-05-22 13:44:37
Your offset time is: 2025-05-22 13:44:37