ForumsProgramming Forumi need help with simple game

11 4862
FutterWacken
offline
FutterWacken
47 posts
Nomad

im currently creating a game which involves getting a coin( cant get the score to rise above 1)
and the coin vanishes off screen
so plz correct this code(as2):
if (_root.coin.hitTest(hero_collect)) {
_root.coin._x = Math.random()*500+50;
_root.coin._y = Math.random()*500+50;
++_root.scorenumber;
_root.score = "Score: " + _root.scorenumber;
}
SUPER THANKS!!!

  • 11 Replies
alsage
offline
alsage
132 posts
Nomad

so whats with the roots? are you doing this within a movie clip or what?

FutterWacken
offline
FutterWacken
47 posts
Nomad

yes i am doing this within a movieclip and if you cant understand what im saying than plz ask for a screenshot or a better explanation
ty

alsage
offline
alsage
132 posts
Nomad

ok can you give me a better explanation of what is going wrong?

FutterWacken
offline
FutterWacken
47 posts
Nomad

ok
the ball touches the coin but score does not go higher than 1
sometimes coin disappears off screen
see for yourself

alsage
offline
alsage
132 posts
Nomad

I figured out first problem... the disappearing thing
Its quite an easy solution

_root.coin._x = Math.random()*500+50;
_root.coin._y = Math.random()*500+50;

that means your coin will re appear at 550 on the x and y axis when your file is only 500x400...

_root.coin._x = Math.random()*400;
_root.coin._y = Math.random()*500;
alsage
offline
alsage
132 posts
Nomad

sorry it will still disappear from screen sometimes unless you subtract coins width from 400. and height from 500... and that border you have around might also hide it

FutterWacken
offline
FutterWacken
47 posts
Nomad

DUDDDDEEEE
thanks but what i REALLY need is the score problem solved
p.s: did you like it?? ^_^

alsage
offline
alsage
132 posts
Nomad

Still trying to figure out the score problem but I just noticed that and I decided to put it in... The score is a bit confusing I dont see why its not working. and yes the game is really cool It is going to be an awesome game to have on the site =D

ug5151
offline
ug5151
587 posts
Nomad

Look on the Internet. There's lots of stuff on that.

FutterWacken
offline
FutterWacken
47 posts
Nomad

@alsage aww thnx a LOT!!!
its mai first real bit of code really
the others were just tips and tricks off the internet and stuff

@ug5151 i already looked, there is NOTHING!! =(

25wes25
offline
25wes25
1,584 posts
Nomad

try makeing another coin and have the same AS and instance name so u can fool it.

Showing 1-11 of 11