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! / If sprite hit (1,50) then "what?"

Author
Message
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 24th Aug 2005 20:50 Edited at: 25th Aug 2005 06:23
Im making a Jawa game. I need prite one to stop when it hits sprite 50. Take a look. (the code isnt very long)
Thanks.

Weird = Unique. Unique = Human.
Im human.
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 24th Aug 2005 21:13 Edited at: 24th Aug 2005 21:14
(I dont just want sprite one to stop, I want sprite 50 to be a wall..sort-of. But I want sprite one to be able to move away from the wall)
Thanks

Weird = Unique. Unique = Human.
Im human.
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 25th Aug 2005 01:48
this is a very basic implementation of collision (only vertical and horizontal walls)

P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 25th Aug 2005 06:22
Oh yeah! Sorry. Im using DBC. I dont think that code works for Classic.

I know how to detect collision, but not how to make collision stop the "player" (sprite 1)

Weird = Unique. Unique = Human.
Im human.
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 25th Aug 2005 06:26
it can still be helpfull. notice how i have xspeed and yspeed values that contain the speed for the player so when i move the player i add/subtract the speed from the players position.
when you hit a wall you can just set the players xspee/yspeed to zero.

P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 25th Aug 2005 06:29
oh....thats a good idea...i never thought of it that way. Ill experiment with it. Thanks.

Weird = Unique. Unique = Human.
Im human.
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 25th Aug 2005 06:47
Yet another problem. I gave the sprite 4 different speed variables, one for right one for left down and up. Now when i hit the "wall" it stops my left speed. (so i cant go through the wall.) but now even if im not touching sprite 50, i still cant go left. Grrrrr

Weird = Unique. Unique = Human.
Im human.
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 25th Aug 2005 07:31
give it just two speeds xspeed and yspeed; when your going up subtract from yspeed, goind down add to yspeed, right add to xspeed, left subtract from xspeed.
make sure that you do not update to sprites position until after you are sure it hasn't hit anything. ie;


P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 25th Aug 2005 20:43 Edited at: 25th Aug 2005 20:47
Im not sure i understand what you mean. Once i stop the left speed, its stopped permanently. Even after i move up above the wall. I can still go right and up and down but not left. I know that i could add another if then statement

if cy<200 then lxspeed=2

this says if sprite ones y (cy) is above the top of the wall than it gets its speed back.

that would work...but since my barrier is a rectangle i would have to do that to the top the left and the bottom sides of sprite 50.

i was wondering if maybe i could just do it in one single "then" like maybe have a different set of variables for the x and y (like hitx and hity) for when sprite 1 hits sprite 50. But i cant figure that way out.

The reason I dont want to use the way ive been experimenting with, is because im going to have to do this to alot of sprites. But ill do it if its the only way...

I also had another idea, I could have sprite 50 which is rectangular, sit in the one spot, while sprite like 51 (just a strait invisable line) would gaurd the top of sprite 50. but if i did that i would need to have 4 sprites for every one sprite i had.
(4 sides to cover)

Wait....now im onto somethin', I could have 8 line sprites. 4 of them gaurd one collision spot. And the other 4 gaurd another collision spot. (if there is one) This way would work but I would need to position the lines pretty well. This shouldnt be too hard. Also, if the line sprite is like 50 pixels across and i need to use it to cover a 20 pixel sprite, i can just use resize sprite.

There are my ideas, Ill start experimenting with them.

Weird = Unique. Unique = Human.
Im human.
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 25th Aug 2005 20:44
I dont know if that made sense, let me know if it dosn't.

Weird = Unique. Unique = Human.
Im human.
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 25th Aug 2005 22:38
It does not make sense, and you are thinking it too much, there is a better (maybe even simplier) way of doing it.
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 26th Aug 2005 00:39
how about you post the code as it is now so we can look at it

P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 26th Aug 2005 17:07
Ill post my "current" code, my codes been changing a whole lot lately.
Here it is. Right now, this code is is detecting a sprite collision while sprite one is in a certain boundries. THe problem is, i need to do 4 different boundries for every ONE collidable sprite.

Quote: "It does not make sense, and you are thinking it too much, "

I AM thinking about too much. Overload. Overload.

Weird = Unique. Unique = Human.
Im human.
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 27th Aug 2005 01:27
try this

P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 29th Aug 2005 07:30
The collisions in that worked well, but when I press the upkey the sprite goes up, but really fast. Same with the left key. I dont like that style of movement either. I think that if I'm going to use the old way of moving I'll just have to buck up and do it the hard way. (Program in the exact collisions.) (if spritex = f then fspeed = 0 )

Even though this didn't help the game much, you definately helped me. I never even thought of having a sprite speed. Its really opened a lot of doors.
Thanks for your help.

Weird = Unique. Unique = Human.
Im human.
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 29th Aug 2005 15:34
no worries.
to reduce the speed just reduce the xmax and ymax values from 10 to say 2 or 3

P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
Ooska
21
Years of Service
User Offline
Joined: 29th Aug 2004
Location:
Posted: 29th Aug 2005 17:05
I did, I lowered em down to one (high speeds scare me) But the same thing happened.

Weird = Unique. Unique = Human.
Im human.

Login to post a reply

Server time is: 2026-07-08 10:17:25
Your offset time is: 2026-07-08 10:17:25