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 / SetSpritePosition Physics Problem?

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 19th Dec 2014 13:03
Hi.

I wrote a code that player collide with box and can push it. but there is a Problem when player collide to box no have real physics and Crossing from box. where is the Problem?

this is my code:

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th Dec 2014 17:02
You are setting the position of your pushing sprite manually. When you set the position of a dynamic physics sprite it messes the physics up. You should be moving your player using SetSpritePhysicsVelocity.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 19th Dec 2014 17:30
Quote: "You are setting the position of your pushing sprite manually. When you set the position of a dynamic physics sprite it messes the physics up. You should be moving your player using SetSpritePhysicsVelocity."


yes I Know but I decide to use SetSpritePosition for fix climb ladder at below link that after few days anyone couldn't give me stable solution.

http://forum.thegamecreators.com/?m=forum_view&t=212934&b=41
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 19th Dec 2014 22:41
We did give you a stable solution: don't use physics.

-- Jim - When is there going to be a release?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 20th Dec 2014 07:51 Edited at: 20th Dec 2014 07:59
Quote: "We did give you a stable solution"


your solution good not work.use ladder is Attractive for me, because seem anyone don't work with ladder in AppGameKit because anyone no have any solution that can work fine. or maybe anyone can't work with it in AGK.

Quote: "don't use physics."


how?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Dec 2014 10:00
i made a Example for you


AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Dec 2014 11:48
I am working on a platform game that uses ladders at the moment but I am not using physics for the character. It makes things a little more logical and easier to control.

I would share my code but it's very complicated because I am using a lot of other stuff that I can't easily extract.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 20th Dec 2014 11:55
Quote: "I would share my code but it's very complicated because I am using a lot of other stuff that I can't easily extract."


Thanks baxslash. I need an example that understand how can climb up and down from ladder.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Dec 2014 14:56
Ok, I'll write a basic example of a basic non-physics platformer for you. I don't really have time but you need the help I think. Once you have that you'll be off to a good start I hope.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 20th Dec 2014 17:22
Quote: "Ok, I'll write a basic example of a basic non-physics platformer for you. I don't really have time but you need the help I think. Once you have that you'll be off to a good start I hope."


thanks my friend.
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 22nd Dec 2014 05:30 Edited at: 22nd Dec 2014 05:32
If you're set on using physics and positioning a dynamic object manually, it is easy to work around. I wrote a screenwrap function for my current game that deals with physics objects that require to re-position objects manually.

Here's a basic version of what I do:



With this code you can essentially teleport any sprite from one point to another and it will keep it's speed and direction of movement with no pause or hiccups.

<a href="http://www.slidedb.com/games/kayak-escape" title="View Kayak Escape! on Slide DB" target="_blank"><img src="http://button.slidedb.com/popularity/medium/games/34310.png" alt="Kayak Escape!" /></a>
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Dec 2014 10:26
there is also a option kinematic,it push all out the way.
SetSpritePhysicsOn
3=kinematic

@JLMoondog
thats not good because it skip the physics system.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Dec 2014 10:29 Edited at: 22nd Dec 2014 10:33
Here's a character controller for you to tinker with. It's not as simple as I'd hoped but I've tried to put all the basics for a platformer in there. I've left moving platforms out for now but if you get stuck I'm sure I'll hear from you


Markus, Josh's code actually does skip the physics system if it's used every frame you are right but for just repositioning a sprite for an occasional teleport it should be fine.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 22nd Dec 2014 12:59
Thanks baxslash. but your code don't compile and give error. also I use AppGameKit V1.

seem this code is not simple but try and if there is any problem if possible I ask you.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Dec 2014 13:19
Oh, yes it uses some V2 code. I didn't consider that. The compiler should still tell you what needs changing. Let me know if you have any trouble...
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 22nd Dec 2014 15:22 Edited at: 22nd Dec 2014 15:22
Quote: "@JLMoondog
thats not good because it skip the physics system."


Actually it works perfectly. Take a look:


<a href="http://www.slidedb.com/games/kayak-escape" title="View Kayak Escape! on Slide DB" target="_blank"><img src="http://button.slidedb.com/popularity/medium/games/34310.png" alt="Kayak Escape!" /></a>
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Dec 2014 15:30
@JLMoondog
yes,i believe but side effects can occur.

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 22nd Dec 2014 16:44
I'm curious what you've found? All my trests ive had no issues.

<a href="http://www.slidedb.com/games/kayak-escape" title="View Kayak Escape! on Slide DB" target="_blank"><img src="http://button.slidedb.com/popularity/medium/games/34310.png" alt="Kayak Escape!" /></a>
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 22nd Dec 2014 21:22
@baxslash

really understand this code is hard. you don't any idea for climb up and down from ladder that don't use this code?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 22nd Dec 2014 22:44
for the ladder problem, u can use a up force so the player not falling down
or some kind of Joints.

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: 22nd Dec 2014 22:52 Edited at: 22nd Dec 2014 23:24
Quote: "for the ladder problem, u can use a up force so the player not falling down"


I test this way but don't work in all system and slowly falling down.

EDIT: maybe my Project have Problem because SetScissor() work in another Project and don't work at The main Project.also use force work in another Project and don't work in the main Project. I should rewrite my Project and check for working up force then there is any Problem I say at this topic.

Thanks.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 23rd Dec 2014 15:37
this is a example that used force for climb up ans stay on the ladder when UP key or down key is released. but when I use up key and release it, sprite automatically move up.

I attached my Project.

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Dec 2014 23:20
yes, look at your conditions and variables

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 23rd Dec 2014 23:25
There's going to be a very long credit list for this project when it gets published in 2097!

-- Jim - When is there going to be a release?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 24th Dec 2014 14:42
this code is for 29 games. only I loadImage to it.I find the problem, when I use "SetSpriteAnimation" and collide to ladder, Player move up automatically. else Script work very well. i don't know why occur this Problem.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 25th Dec 2014 09:37
is this a bug? mean "SetSpriteAnimation" don't work with "SetSpritePhysicsForce"?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 25th Dec 2014 21:45
can anyone help me?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 26th Dec 2014 13:32
any idea? can anyone tell me why occur this Problem?
Yodaman Jer
User Banned
Posted: 26th Dec 2014 18:54
Double-bumps are really frowned upon.

MAybe if you gave us more information than "is this a bug? mean "SetSpriteAnimation" don't work with "SetSpritePhysicsForce"?", we might be able to offer insight on what's going on. We need a lot more information than just a vague question.

Just out of curiosity, have you studied the documentation at all? Followed any tutorials? Judging by how many threads you post asking all of sorts of questions I'd hazard a guess and say "probably not". The documentation is very comprehensive and gives you a lot of examples, I highly recommend you go through it thoroughly before attempting to make any kind of game, let a lone a physics-based platformer!

I don't mean to sound rude, I'm just trying to give you a push in the right direction and save you time better spent coding.


7+ years and counting!
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 26th Dec 2014 20:28 Edited at: 26th Dec 2014 20:29
Quote: "MAybe if you gave us more information than "is this a bug? mean "SetSpriteAnimation" don't work with "SetSpritePhysicsForce"?", we might be able to offer insight on what's going on. We need a lot more information than just a vague question."


I add my code in upper post. all give you all information. you disable "SetSpriteAnimation" and see what's happen.then enable it and see again what's happen. when "SetSpriteAnimation" is enabled anfter collide to ladder, automatically move up.

Quote: "Just out of curiosity, have you studied the documentation at all? Followed any tutorials?"


Yes.Just out of curiosity you know where is climb ladder example in AppGameKit? maybe I can't see it.

Quote: "I highly recommend you go through it thoroughly before attempting to make any kind of game, let a lone a physics-based platformer!"


I made a Physics platformer game with Game-editor. but All things in AppGameKit is vice versa. I wrote climb ladder in Game-editor Engine at 5 minutes like below code.but this way don't work in AGK. it's funny.



but more that one week not me and anyone can't write physics code for climb ladder in AGK.

I think You can see hidden Examples and hidden notes in documention. and can wrote a code for climb ladder.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 26th Dec 2014 20:33
There is no physics in the example code above.
That is the kind of thing that everybody has suggested you do - write a platformer that doesn't use physics.

Convert that to AppGameKit and stop insisting on using the physics commands.
Yodaman Jer
User Banned
Posted: 26th Dec 2014 20:37
It's apparently his way or no way, despite multiple users warning him of all the inherent "bugs" that using physics for a platformer would cause him.


7+ years and counting!
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 26th Dec 2014 20:40
Quote: "There is no physics in the example code above.
That is the kind of thing that everybody has suggested you do - write a platformer that doesn't use physics.

Convert that to AppGameKit and stop insisting on using the physics commands."


Game-editor is GUI engine I add Physics to another Part.

Yodaman Jer
User Banned
Posted: 26th Dec 2014 20:46
...Right, he's saying convert the code you wrote in Game-Editor for your ladder to code that would compile in AppGameKit, and there's your solution.


7+ years and counting!
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 26th Dec 2014 20:48
I tried but don't work.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 26th Dec 2014 20:58 Edited at: 26th Dec 2014 20:59
in Game-editor below code is same with SetSpritePhysicsVelocity and SetSpritePhysicsOn in AGK:


Game-Editor:



and I convert it to AppGameKit Like below, but don't work:

Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 27th Dec 2014 00:41 Edited at: 27th Dec 2014 00:42
You can not convert an event driven function you know nothing about, into AppGameKit like that... Game-Editor is an event driven language, like visual basic, and it uses a special NON PHYSICS pixel perfect collision system.

Game-Editor does NOT use physics! it does NOT use Box2D, as AppGameKit does. It only uses a simple pretend-physics system, that can not rotate sprites based on collisions, and does not work with friction and stuff that Box2D uses.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.

Login to post a reply

Server time is: 2024-11-25 14:41:01
Your offset time is: 2024-11-25 14:41:01