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.

Newcomers DBPro Corner / Creating a room for a sprite to move thro in 2d

Author
Message
NickHudson
15
Years of Service
User Offline
Joined: 19th Mar 2009
Location:
Posted: 19th Mar 2009 18:07
Hi all,

Im very new to this - so apologies in advance!

I need a program where a sprite moves thro a room from one door to another. At the minute I just want the sprite to go directly between the doors (a straight line!!) but in the future there will be more than one sprite, and based on behaviour rules, they should enter the room, move around, and leave at different times/rates.

I have the walls, and the doors (gaps) set up, and can have a sprite sat where i want it (only as an image). however, when i change the image to a sprite, it does not appear where i want it, tho i can get it to move a little.

im very confused, and have tried using many tutorials on the forum, but nothing seems to be shifting - i just end up with the walls, and a sprite, but no movement at all.

any help would be appreciated guys...here's my code...

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 20th Mar 2009 17:58
I have some questions for you:
1. Are you trying to make a top-down game and is it supposed to be through a maze? You have placed your objects at different Z depths and I don't know what it is that you are trying to do.
2. Is the sprite for a player, NPC or what? Why use a sprite at all? Why not use an object? You have created objects, not sprites, and set them up for collision.
3. I assume you are expecting the screen to stay put while the player/NPC/whateva moves, is that right? The sprite you made moves where you told it to go (when pressing the right arrow); to move right as long as the value in entity_x is less then exit_x. Once it reaches exit_x (97.5), it stops. Coding it like that will be tedious, as you will have to pre-establish a maximum right movement in every part of your maze/terrain/world. It would be better to check for collision if you move so many units to the right, and not move it if there is a collision with an object. The same would go for up, down or left movement.

NickHudson
15
Years of Service
User Offline
Joined: 19th Mar 2009
Location:
Posted: 21st Mar 2009 18:31
hi,
many thanks for the reply. yes it is supposed to be a top down view of a room, and there is not supposed to be any z movement. im only using a sprite as i thought they were the easiest to manipulate.

I'm unaware of the differences in z depth...could you point these out?

I am supposed to be modelling how people move through a room, so I think the collision detection would be better rather than moving set number of pixels through the image.

Do these extra facts help? Am I anywhere near the right lines?

Nick
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 21st Mar 2009 19:21
So, your intent is to have just one room?

Z depth is related to placement of object on the Z axis. I was mistaken; I thought you had set a couple of the objects at 5.0 on the Z axis, but you have them all at 0. My bad.

To me it would be easier to make the sprite into an object and then check collision. A really crude version:




You can use the 'U' key to move the camera up and the 'D' key to move it down.

If this is a school project with just one room then the standard collision checks should be fine. If you are working on a game, you should search for Sparky's collision and use it instead.

NickHudson
15
Years of Service
User Offline
Joined: 19th Mar 2009
Location:
Posted: 25th Mar 2009 18:43
hi mate,

thanks very much for your help.

The only issue at the minute is that there is no collisions. My moving object can just move straight through the walls.

Is there a part of the code missing?

Nick
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Mar 2009 19:50
Quote: "The only issue at the minute is that there is no collisions. "


Huh? When I run the code, the collision works fine and the moving object stops when it hits the wall. I just checked it again and got the same result.

NickHudson
15
Years of Service
User Offline
Joined: 19th Mar 2009
Location:
Posted: 1st Apr 2009 16:56
Hi,

I have just tried it again, and I do NOT get the collisions working!

I am pasting the code directly into DarkBasic Pro. I hit the "make exe/run" button, and it tells me
"parameter for INK do not match 'foreground colour,background colour' at line 78"

so i grey it out and ignore it. does INK have anything to do with collisions?

I still do not get the moving object stopping at the walls.

Any help is appreciated again!!

Nick

Login to post a reply

Server time is: 2024-09-28 04:20:21
Your offset time is: 2024-09-28 04:20:21