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 / physics issue

Author
Message
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 8th Jun 2013 00:07
ive just finished making the game pong and have just started working on new levels. when all of the bricks have been hit a variable named level is incrimented, for each level positions of the bricks and ball are reset but the code
moves the ball but it just sits and spinns even when i turn the physics off and on it does it, changing the velociuty does nothing. but if i dont move the sprite it works perfectly fine... what could be wrong please?

kirtnicholls
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Jun 2013 00:47
Well, showing a single line doesn't really help without knowing its full context.

The line you show is missing the closing parenthesis, I assume that was just a copy/paste error.

And the code you show doesn't move anything. It simply sets the position. If you are calling that in your play loop, it resets the position every loop to the same spot.

We need a bit more context of the the commands. You don't give any indication of how the sprite is supposed to be moved.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Jun 2013 10:52
here i have an example i had made for other user

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Jun 2013 19:24
Well I just tested the code you posted and it seems to work just fine. Including the ball not spinning when reset after

So I don't think it relates to your original post.

In the code that prompted you to post your issue, are you using the SetSpritePhysicsAngularVelocity command to stop the spinning (which appears to be your complaint in the original post) as you use it in the code you just posted?

And are you also resetting your states (as you appear to be using in the posted code)?

As a suggestion, try using a switch/case setup with your state instead of the 'if' statements. It would help to visually organize your code.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Jun 2013 23:39
@Ancient Lady
did you tested my code for kirtn14?
(switch case don't work as expected in agk for some situations)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Jun 2013 06:09
I tested the code that you posted in the post just before I responded.

I had fairly good luck with the switch case in Tier 1. As long as it was set up correctly and the initial state was correct.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Jun 2013 09:32
I use the select/case commands in T1 all the time, in what situations do they not work Markus? I have never had a problem with them...


this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Jun 2013 11:14
OT
@baxslash
i put something together, its similar i uses as select true in other languages.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Jun 2013 11:32
You are using it wrong.

Example:



this.mess = abs(sin(times#))
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Jun 2013 12:03 Edited at: 9th Jun 2013 12:22
off topic
@baxslash
(i remember me, we used this kind for option buttons,
one of the option was true and therefore the select true.)

the same don't work, its just a agk issue.


the same in visual basic 6 works
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Jun 2013 13:29
I think it works if you use constants, not sure about variables... Nevertheless the way you showed it earlier doesn't work. You need to provide a variable for select and a constant for case.


this.mess = abs(sin(times#))
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 9th Jun 2013 14:40
Aren't you supposed to put colons after the case selector:

Case Apple:
Message....etc
Endcase

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Jun 2013 15:54
@JimHawkins
with colons is the same, agk want constant values at case.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Jun 2013 18:22
It is pretty much a requirement in all languages that the case statements use constant values.

Using variables of any sort just doesn't work.

JimHawkins, I too added the colon as a matter of previous usage. But it is not required in AGK. I think it still works because AppGameKit just treats it as a continuation to the next line.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 9th Jun 2013 19:14
Thanks, AL. I merely looked at the AppGameKit help on it!

I agree the instances must be constants.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
kirtn14
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location:
Posted: 10th Jun 2013 21:03
sorry for not replying for some time, I've been other wise engaged.
this is the script that I am having issues with


this is the section of the code that is not working


thanks

kirtnicholls
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 10th Jun 2013 22:30
You are doing an awful lot of stuff in your do loop. And much if it looks repetitive or non-functional. Of specific concern is the if group for 'if level = 2'. When you reach destroyed = 24 the first time, level gets set to 2 and all your sprites are repositioned. And they will be repositioned every loop, regardless of anything else, after that and it is unlikely that the level will change because the relevant sprites are all being reset and won't be destroyed. You need to do something so that that set of position settings gets done once and the if statement triggering them isn't triggered again in the next cycle.

I don't think you quite understand the Sync() loop. You repeatedly check the pointer (two different) ways as if you expect that it might change in between checks. The Sync() call is what causes updates to all physics and pointer checks and such. Nothing changes again until the next Sync() call (including your position settings).

You are doing a lot of checks for pointer state followed by hit checks and then do nothing. I guess you mean for those to be stubs?

You also appear to be expecting multiple things to happen to the same sprite in the course of one Sync() cycle and it doesn't really work that way. From the way you appear to be setting up the display, the ball(s) will only make contact with two adjacent bricks at most. They cannot hit multiple bricks in different locations in one Sync() cycle.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 10th Jun 2013 22:45
i used print("Problem") at this part and see you are set
all the same in a loop.
(because copy/paste from web is was indented chaotic.)

you should use more functions for a better overview.

Login to post a reply

Server time is: 2024-05-03 01:46:49
Your offset time is: 2024-05-03 01:46:49