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 / Help with score counter

Author
Message
sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 18th Jan 2013 03:46
I'm having a problem with my counter. When I run the program the count increases by one but not every enemy killed counts. And when i collect a key It won't count up at all. I don't know what I'm doing wrong.
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 18th Jan 2013 06:47
Is your code snippet wrapped up in a function? If so you'd have to make a few variables global. If not, how is it being executed? I can't see a sync() command anywhere nor a continuous loop.

sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 18th Jan 2013 13:47
Thisis how I am using it. 1000+e is the enemy and 10+b is the weapon. 213 is the key and 1 being the player.
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 18th Jan 2013 15:36
First for Next loop:

Are your sprites numbered 2000 to 2010 ?
and 20 to 110 ?

Second For Next Loop:

k is not used in the loop ?
sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 18th Jan 2013 15:51
First for next loop sprites are numbered 1000 to 1010
and the second loop i forgot to delete the for next. It is just a single animated sprite 213
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 18th Jan 2013 16:27
First Loop looks as if the next statements may not be in the correct order:

next e
next b

From the code provided the sprites are numbered 2000 to 2010 etc: but thats probably not an issue as you create them the same way.

I can not see any issue with the keys unless for some reason the sprite id's are not correct.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Jan 2013 16:39

You might be very lucky that this worked. Assuming this is your first set, the 'e' in the loadimage command defaults to zero.

And your sprite ids are 2000 to 2010.

TrezSoft is correct, the bad ordering of your next statements is causing most of your problem, probably.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 18th Jan 2013 20:15
I have many for next loops setup. Does that mean that each letter I created are all default 0? Is there a better way to implement this?
for b=10 to 100
for t=300 to 350
for t=351 to 400
for l=600 to 625
for s=651 to 700
for r=701 to 750
for f=751 to 775
for f=776 to 800
for e=1000 to 1010
for d=1011 to 1021
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 18th Jan 2013 20:28
Its hard to tell without seeing more code.

when you setup a variable they are by default = 0. so in the snippet from AL above if e is not set to some value before the loadImage then it would be 1000+0.

if you are using for next loops then the values are defined in the for loop.

so for example your code above could be created as follows



now the sprites are numbered from 1000 to 1010 because that is what you are assigning in the for loop to e.

lookup cloneSprite in the help. This way if you are creating identical sprites you can create the sprite once and then clone it in the for next loop.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Jan 2013 20:31
Until a variable is assigned some value, it is zero.

The moment it is used, like in a for loop, it has a value.

The sample code you showed "loadimage ( 1000+e, "zombie_001.png" )" is using the 'e' variable. I don't know if you intended on doing that.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 18th Jan 2013 20:38
On a side note it may be worth investing in a small donation to Daniel's AppGameKit Teach Yourself App Game Kit ebook. The donation will give you early access to the ebook which already covers these topics very well.

http://forum.thegamecreators.com/?m=forum_view&t=202520&b=41
sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 18th Jan 2013 20:41
Thank you both so much that was the problem. By setting it up the way TrezSoft posted removing the +. It is all working correctly.

Login to post a reply

Server time is: 2024-05-03 21:30:50
Your offset time is: 2024-05-03 21:30:50