The Armor Games website will be down for maintenance on Monday 10/7/2024
starting at 10:00 AM Pacific time. We apologize for the inconvenience.

ForumsProgramming ForumI'm making a tutorial...

14 4947
ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

Recently, my 30 day trial of Adobe Flash CS5 ended.

All I've got to show for it is a (very) simple game.

In it, a ball bounces around and you have to click on it. When you do, you get 1 point and the ball teleports to a new location.

A lot of my 30 days was spent hunting books and internet resources to make it. I think that if I made a tutorial for the ball bouncing thing, then other people on the trial wouldn't have to hunt everywhere.

BUT... I'm not sure if the code I'm using is the best way to do it. So I'm asking the awesome people at AG to look at my code and see if it can be improved, so that I don't end up teaching bad practices in the tutorial.

The ball is called button. The text box containing the score is called scoreBox.

var score:Number = 0;
var hdirect:Number = Math.random()*10;
var vdirect:Number = 10-hdirect;
trace("Horizontal direction: " + hdirect);
trace("Vertical direction: " + vdirect);

button.addEventListener(MouseEvent.CLICK,addone);

function addone(e:MouseEvent)
{
score += 1;
trace(score);
scoreBox.text = score.toString();
button.x = Math.random()*520;
button.y = Math.random()*370;
hdirect = Math.random()*10;
vdirect = Math.random()*10;
var random1 = Math.random();
var random2 = Math.random();
}

button.addEventListener(Event.ENTER_FRAME,movement);

function movement(e:Event)
{
if (button.x > 520)
{
trace("hit!"
hdirect -= hdirect*2;
}
if (button.x < 0)
{
hdirect -= hdirect*2;
trace("hit!&quot;
}
if (button.y > 370)
{
trace("hit!&quot
vdirect -= vdirect*2;
}
if (button.y < 0)
{
trace("hit!&quot
vdirect -= vdirect*2;
}
button.x += hdirect;
button.y += vdirect;

}

  • 14 Replies
master565
offline
master565
4,104 posts
Nomad

If it works fine then it looks good.

I'm not sure if this is a problem but you put

scoreBox.text = score.toString();

In the mouse event. I'm not sure if its better but i usually put that in an enter frame event so that it refreshes the score faster. It might not be useful in this case but its nice to know.

master565
offline
master565
4,104 posts
Nomad

I forgot to add, the only real problem is if you stole code from places. Did you?

ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

Thanks

No, I did all the coding work myself.

ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

">test

Sorry, there is no place for forum testing, so I'm doing it here.

Secretmapper
offline
Secretmapper
1,747 posts
Nomad

test

Sorry, there is no place for forum testing, so I'm doing it here.


I think Javascript ain't accepted. or something
ide4749
offline
ide4749
310 posts
Nomad

wow real cool

ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

Dang. I was hoping it would, so that I could have extra information &quotop up" so that it doesn't clutter the main tutorial...

ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

Oh, and secretmapper, how did you know it tried to link to javascript?

ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

Here's another test.

A QUOTE
WITHIN A QUOTE
WITHIN A QUOTE
Dannydaninja
offline
Dannydaninja
948 posts
Nomad

Nice tut, completely worthless to me, but nice tut.

I look forward to you buying flash. Otherwise that 30 days of searching for tut's and reading books would have been a waste. Buy it. You can profit from it with the games you make

I only have to make another $529 until I profit from buying flash, at this rate I'll be there in only 20 years!

ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

I can still use Flash every Tuesday and Wednesday at the computer labs at my school.

How does making flash games make money though?

Dannydaninja
offline
Dannydaninja
948 posts
Nomad

Sponsors buy the flash game.

ExplosionsHurt
offline
ExplosionsHurt
248 posts
Nomad

oh, ok thanks

Dannydaninja
offline
Dannydaninja
948 posts
Nomad

But Kongregate.com will accept any games, and you automatically get paid your fair share of ad revenue ( between 15% - 50% ).

I've made about $30 from Kongregate.

But getting the game sponsored can make thousands of dollars if it's a good enough game.

Showing 1-14 of 14