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 / Problem with SetViewOffset()

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Jun 2015 17:55 Edited at: 5th Jun 2015 17:59
Hi.

I made a game like flappy bird and for jump the bird I used
command. but there is an problem, mean Sometimes the screen vibrates. I changed SetSpritePhysicsVelocity() with SetSpritePosition() for find the problem and understood problem is relate to SetSpritePhysicsVelocity() command.

This is my simple code for jump player, please guide me to fix it.



Thanks.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Jun 2015 18:49 Edited at: 5th Jun 2015 18:51
this is full code for better understand:



Note: Use left mouse for jump
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 5th Jun 2015 19:05
You need to look at SetSpritePhysicsImpulse. (I'm sure we've had this conversation before haven't we?)

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Jun 2015 19:21 Edited at: 5th Jun 2015 19:22
Quote: "You need to look at SetSpritePhysicsImpulse. (I'm sure we've had this conversation before haven't we?)"


Maybe, but sure it's not relate to this project.

I used SetSpritePhysicsImpulse() command for my bird, but it's make rotate bird after click on the screen. even I used SetSpritePhysicsCanRotate(player,0) for stop rotate, but don't fix.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Jun 2015 19:30
With SetSpritePhysicsImpulse(), the impulse has to go through the centre of the sprite, otherwise it will spin.

It's like hitting a ball with your fist; if you hit the edge, it will spin instead of move forwards.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Jun 2015 19:34 Edited at: 5th Jun 2015 19:50
Quote: "the impulse has to go through the centre of the sprite, otherwise it will spin. "


right, with SetSpritePhysicsImpulse(player,GetSpriteXByoffset(player),GetSpriteYByoffset(player),0,-100)

I fixed rotate sprite, But there are still shaking for sprite.



I think use SetSpritePhysicsImpulse() command not a good idea.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Jun 2015 21:07 Edited at: 5th Jun 2015 21:29
anyone have idea?
how can make this jump without use Physics?

this is my code with SetSpritePhysicsImpulse() command that can see don't have control on player jump.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Jun 2015 13:48 Edited at: 6th Jun 2015 13:49
ca anyone help me?

I finished my game but still have problem with physics jump.

I do not know when TGC Decide fix these Physics bugs.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Jun 2015 18:53 Edited at: 6th Jun 2015 18:56
Quote: "I do not know when TGC Decide fix these Physics bugs"


It's not a physics bug, it's a misunderstanding of how physics commands work.

Here is a box controlled by velocity and impulse, and offsetting the view so it is always in the middle.



Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Jun 2015 20:37 Edited at: 6th Jun 2015 20:38
thanks BatVink but your code is same with my code at latest post.

my problem is relate to this jump.it's not like flappy bird jump.

only SetSpritePhysicsVelocity() can make a jump like flappy bird with easy control. but this command create a vibration on sprites.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Jun 2015 00:07
Try smoothing out the setviewoffset by averaging out the last few frames?

Or you could follow an invisible placeholder sprite that uses a tween with tweensmooth() to stop it from vibrating.

Or set a maximum velocity for your setviewoffset to prevent it 'snapping' to a new position.

In fact, if the physics is too much, do it a non physics way such as:



V2 T1 (Mostly)
Uzmadesign
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jun 2015 00:26 Edited at: 7th Jun 2015 00:26
You need to experiment with the values. When you try something new, look through the commands available, and mess around with them to understand what they do.

In my example above, I've decreased the physics scale, reset the velocity everytime you press the spacebar and changed damping depending on rise or fall. I've also set the sprite angle according to the speed of rise and fall. 10 minutes work and I have a Flappy Bird.

I had no idea how to do it before I started. I just made changes, observed the result and fine-tuned it as I went along.



Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jun 2015 01:16
15 more minutes and here is a full framework...
Again I stress, I just kept experimenting with different values until it worked how I wanted it...



Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Jun 2015 12:31 Edited at: 7th Jun 2015 14:05
Thanks BatVink, But there are still shaking on phone.

Note: I have AppGameKit v1.

@CJB

I will check your code.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Jun 2015 21:53 Edited at: 7th Jun 2015 22:13
I test all codes for fix this problem But there are still shaking.

To ensure correct my work I removed all images and sprites Except player, and tested it again and seen there are still shaking and made me more confident.

all things are Ok in PC but when run it on Phone, there are shaking and Pause.(I tested it on two different device)

I don't know what is this problem, and I'm sure this is another physics bug like (climb ladder in platform game).and this is My second defeat at make physics game with AGK.

I feel at this time that I wasted my time, I worked with AGK. because it have Many bugs.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Jun 2015 23:40
I just tested my code on 1.08 on a mobile device - no shaking.

What did you do to check my code for suitability? It doesn't run on 1.08 without a number of changes.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jun 2015 02:51
Quote: "I will check your code."


Not sure what you need to check. Just copy/paste and run. Also, it wasn't my code. I just took the simple example that BatVink gave you and altered it so as to give the effect you were after without the need for a full physics system.

Did you manage to get your flappy bird clone working? Personally I think you should forget about cloning other games and have a go at writing your own. Rezalt's Eternal Escape is a good example. Make your own control system and get it working the way you want it to work.

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 07:38 Edited at: 8th Jun 2015 08:14
@BatVink

this is a extract my code:



In this code there are shaking and pause.
if possible please check my code.

@CJB

Quote: "
Did you manage to get your flappy bird clone working? Personally I think you should forget about cloning other games and have a go at writing your own. Rezalt's Eternal Escape is a good example. Make your own control system and get it working the way you want it to work."


yes, I used cloning for my game. I only have 5 pipe and I changed the position and height size of each of them after outside of view.


Thanks.
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 8th Jun 2015 09:35
LOL at the reply to the latest quote

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jun 2015 10:38
Your code doesn't shake or pause for me on a mobile device.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 11:19 Edited at: 8th Jun 2015 11:24
OK.

my calculate for move player is not correct, player slowly move to out of screen. can you help me to fix it?

problem is relate to this part:

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jun 2015 11:48
It's because when you hit a pillar, you are continuing the game. When you have finished, I assume you will be ending the game when you crash?

The difference between your code and mine is this...You keep moving the view offset forwards all the time. I set my view offset based on the position of the player. So if the player stops, the view offset stops.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 11:58
Quote: "I assume you will be ending the game when you crash?"


yes.

Quote: "I set my view offset based on the position of the player. So if the player stops, the view offset stops."


can you fix it in my code?

and another question is what is your phone?
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 12:31 Edited at: 8th Jun 2015 12:33
@BatVink

at this time I tested my game on my friends phone device (Samsung galaxy note 3) and (Sony Xperia M) and there are shaking and pause on them.

I think all devices can't have problem.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jun 2015 12:56
Quote: "I think all devices can't have problem. "


I agree. It's not the devices that have the problem.

V2 T1 (Mostly)
Uzmadesign
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jun 2015 13:03
My phone is a Nexus 4. The phones you have tested on are good phones, there should be no framerate problem or similar issues.

Add this line before your Sync(), see if it fixes the shake...

StepPhysics(GetFrameTime())

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 13:03
Quote: "I agree. It's not the devices that have the problem."


but what is the problem?
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Jun 2015 13:07
Quote: "but what is the problem? "


I believe the problem is in the chair to keyboard interface.

AGK V2 user - Tier 1 (mostly)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jun 2015 13:10
Quote: "chair to keyboard interface"


Love it! I must use that!!!

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 13:13
Quote: "I believe the problem is in the chair to keyboard interface."


I don't understand your mean.???
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 13:25
Quote: "dd this line before your Sync(), see if it fixes the shake...

StepPhysics(GetFrameTime())"


I tested it, but shaking and pause still exists.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jun 2015 14:06
Do you need to use physics? i.e. Are you planning to have your 'flappy bird' smash through things, or swing on things, or bounce off things etc? If not, then did you try the 'non physics' code example? You said you'd check it, but you didn't come back. It took maybe a minute to make those changes to create a non-physics custom control method. You've been using AppGameKit for quite a while now, so I think you should be able to go and do one.

The Box2D implementation in AppGameKit is not complete, so there are going to be rare scenarios where something might not work exactly as you intend and there will be nothing you can do about it. Like when I couldn't get a bunch of stacked dynamic objects to settle down into their idle state for a 2d scroller I was working on. They'd continue moving the tiniest amount until eventually they toppled over some five minutes later - if the full BOX2d set had been exposed in AppGameKit I'd have been easily able to fix the problem, but meh, I worked around it through experimentation.

Try to think outside the box (2d).

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jun 2015 14:36
Quote: "Do you need to use physics? i.e. Are you planning to have your 'flappy bird' smash through things, or swing on things, or bounce off things etc? If not, then did you try the 'non physics' code example?"


At first thank you for Accept Problem.

I don't need use Physics.I seen your 'non physics' code example, but it no have real jump and control is hard.I work on it again tonight I declare the result.

Quote: "Try to think outside the box (2d)."


I have no problem, but need more help. already said, I learned game making with physics method, and I'm not good familiar with non-physics method.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jun 2015 15:29
Quote: "They'd continue moving the tiniest amount until eventually they toppled over some five minutes later"


Over the years I've used Box2D, Newton, PhysX, Ageia, and others. For some bizarre reason they all seem to suffer from the cold-fusion effect where stacks of blocks generate their own energy and shake themselves to a pile of rubble.

We should harness this power for a greener future.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jun 2015 15:40 Edited at: 8th Jun 2015 15:41
BatVink didn't see any stuttering, and I couldn't see any either so I suspect the problem may be related to your media. Are you using lots of large sprites with see-through bits (it's not unheard of for starters to use a full screen of see-through sprite just for a 32x32 image, instead of a 32x32 sprite positioned in the correct place), or loads of particle effects or particularly intensive shaders in your code etc.?

Put a Print(Screenfps()) in your code and let us know what frame-rate you are getting.

Quote: "We should harness this power for a greener future."
Very green!

V2 T1 (Mostly)
Uzmadesign
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th Jun 2015 17:13
Is your Flappy Bird game working now Behdadsoft? If you post your entire project, I'd be glad to test it on my Android device to see if I get the same problem.

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jun 2015 06:46 Edited at: 10th Jun 2015 06:47
Quote: "Is your Flappy Bird game working now Behdadsoft?"


yes, thanks CJB.

your method now work very well and there aren't shaking and pause.

Quote: "If you post your entire project, I'd be glad to test it on my Android device to see if I get the same problem."


I will be release this project at next week. and before sell it on google play, send it for you.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 10th Jun 2015 10:40
Woohoo! Great I look forward to seeing it! Congratulations.

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jun 2015 10:45
Quote: "Woohoo! Great I look forward to seeing it! Congratulations."


Thanks CJB
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jun 2015 15:03 Edited at: 10th Jun 2015 15:13
@CJB

I sent download link beta version of my game to your email for test on your device and see there is any problem or not.(if Possible).
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 10th Jun 2015 15:11 Edited at: 10th Jun 2015 16:55
Sent


Ok, I've had a quick play of the game and first impressions: I am very impressed.

Without looking at your code, it is difficult to make any recommendations on how to improve performance. I did notice an occasional glitch like a couple of dropped frames every few seconds.

If it doesn't cause too much detriment to visual quality, You could try reducing the size of your background and pipestone images to 512 instead 1024 (would look identical on my little GS2).

When you recycle the pipes, are you deleting and re-creating sprites, or just moving them to the new location?

It might be the look you are going for, but I think the coin animation could be a little faster. The scrolling is really smooth, but the coins are animating at a much lower frame rate.

I think you're onto a winner there Behdadsoft! Good luck with the launch


V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Jun 2015 00:28 Edited at: 11th Jun 2015 10:35
Thanks CJB

Quote: "If it doesn't cause too much detriment to visual quality, You could try reducing the size of your background and pipestone images to 512 instead 1024 (would look identical on my little GS2)."


only for test I reduced the size of my background to (320X400) and pipestone images to (512X512).I think the quality is not low.

Quote: "When you recycle the pipes, are you deleting and re-creating sprites, or just moving them to the new location?"


To avoid frame loss, I doesn't deleting and re-creating sprites and just moving them to the new location.

Quote: "but I think the coin animation could be a little faster"


right, I changed coin animation form 10 to 13, and if you feel coin animation could be a more faster, I will be change it.

Quote: "I think you're onto a winner there Behdadsoft! Good luck with the launch"


Thanks again

I sent new APK to you. if possible check it again.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 11th Jun 2015 13:01
Checked the new version. I couldn't test it too much because it's SO difficult! I'm rubbish at this sort of game. I tried to break it by jumping off the top of the screen, and by letting the little d drop through the flaw, but it responded correctly.

Looking good! Get it published

V2 T1 (Mostly)
Uzmadesign
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Jun 2015 13:06 Edited at: 11th Jun 2015 13:08
Quote: "I couldn't test it too much because it's SO difficult"


LoL. My last record is 98 coin.

Mean there is no any pause and dropped frames??

if think also there are dropped frames I can send my project to you.
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 11th Jun 2015 13:22
@Behdadsoft, I'd happily test this for you as well if you would like. I love these sort of games

Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Jun 2015 13:30 Edited at: 11th Jun 2015 13:33
sure, please send one email to me.
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 11th Jun 2015 14:42
Very impressive indeed Behdadsoft, well done... I get a consistent 59 FPS with no frame drop. Tested as much as I could, but couldn't get a score over 4 lol...

I do think there is a fine balance between making a game hard, and near on impossible. And I think, for me at least, this one is near impossible. But if you have achieved a score of 98 then it must be doable... I'll keep at it and report back...

Other than that, I don't really have anything else to add, the game is very well polished, your logo looks great, the game plays really well (albeit ridiculously hard), and I didn't see any noticeable delays when transitioning, so all I can do is second what CJB said "Get it published"

Using AppGameKit V2 Tier 1
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Jun 2015 15:05
I forget, Thanks CJB for Test and Guides.

OK, Thanks Funnell7 for test.

yes, this game is a little hard. and I want reduce size of dragons and improve jump to simplify it.

after finish the game I send final and English version to you and CJB.

I'm glad you're happy with this game.

Quote: "what CJB said "Get it published""


sure
lilpissywilly
AGK Developer
14
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 11th Jun 2015 15:43
Just a little input on the framerate issue (seems you fixed it but anyway);

If you design a game with 60fps and a user has "power saving" activated on their device the FPS is often limited to 40.

My hovercraft is full of eels
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 11th Jun 2015 15:56 Edited at: 11th Jun 2015 21:39
Quote: "If you design a game with 60fps and a user has "power saving" activated on their device the FPS is often limited to 40."


Thanks,It was a good Point.

Login to post a reply

Server time is: 2024-11-25 22:48:26
Your offset time is: 2024-11-25 22:48:26