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.

AppGameKit Classic Chat / Stop Elevator

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 3rd Jan 2015 14:30
Hi.

I wrote a code that when Press Enter key, Pause = 1 and all things stop.

Now I have elevator that when pause = 1,move slowly to down.if I turn off Physics with "SetSpritePhysicsOff()" it don't move down when pause = 1.
but I don't want turn off Physics. there is any way that fix this Problem?

this is my code:



Thanks.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Jan 2015 14:45 Edited at: 3rd Jan 2015 14:54
at first how about a function and uses it only once in loop
ElevatorGotoTargetY(elevator,y)

thats to much copy/paste with the same doings.
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator)-2)
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator)+1)
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator)-2)
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator))

then u can replace moving 1 2 3 4 by y var for elevator

this u can also better replace with one call below terms and inside terms use deltax#,deltay#
the code will be more readable then for better overview and understanding.
SetSpritePhysicsVelocity(Character_Spr, ...
SetSpritePhysicsVelocity(Character_Spr, 200, ...
SetSpritePhysicsVelocity(Character_Spr, 0, ...
SetSpritePhysicsVelocity(Character_Spr, ...

a good overview in source code is much important if u developing software.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 3rd Jan 2015 17:13
To temporarily pause the physics, you can call StepPhysics(0). This is what I use in my pause routine...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 3rd Jan 2015 18:35
seem use StepPhysics(0) make turn off physics and I don't want. because when I turn off Physics, if player put on elevator then player fall to down.even I turn off Player Physics but I don't know why fall it.
Yodaman Jer
User Banned
Posted: 3rd Jan 2015 18:51 Edited at: 3rd Jan 2015 18:52
Behdadsoft,

How many times must we tell you that using physics for a platformer will cause problems for you?

I would go with Funnell7's idea, just use StepPhysics(0) and that will "pause" physics update accordingly.

Quote: "seem use StepPhysics(0) make turn off physics"


Well yeah, of course it does, until you use something like StepPhysics(0.1) to "turn" it back on again.

But again, you seem to be going against everyone's advice and still using physics for a platformer despite all of the inherent problems it will cause you.


It's back, baby!
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Jan 2015 19:16
its not wrong follow a target, means playing with the physics.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Jan 2015 19:43
this part is wrong.
u overwrite the physics.
normal the elevator falling down.
why not use this kinematic physic flag?
see example below.

if pause = 0
if moving = 1
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator)-2)
else if moving = 2
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator)+1)
else if moving = 3
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator)-2)
endif
endif
endif
else
SetSpritePosition(elevator,GetSpriteX(elevator),GetSpriteY(elevator))
endif



AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 4th Jan 2015 08:53
Thanks Markus. As usual with new solution. really with your help I learn good things about work with Physics.

there is another Problem that when Player put on the elevator can't jump.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 4th Jan 2015 20:57
I find Problem. should use SetSpriteGroup().
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 5th Jan 2015 16:50
Do you mean you found the solution? If so, can you show some example code of how you solved the problem of jumping when on the elevator? It will be a nice way to close this thread. Thanks!

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Jan 2015 12:48 Edited at: 6th Jan 2015 12:49
Quote: "Do you mean you found the solution? If so, can you show some example code of how you solved the problem of jumping when on the elevator? It will be a nice way to close this thread. Thanks!"


this is not my solution. this solution is for Funnell7 that already I seen in him code:

when use PhysicsRayCastGroup(), should create a group for each Sprite like this code:

Login to post a reply

Server time is: 2024-05-19 11:21:11
Your offset time is: 2024-05-19 11:21:11