Monday, 22 June 2009
Site Overhaul
Ultimately i'd get my own site, but this shouldn't happen for a while.
Aswell as the Blog i've also been researching different tutorial methods and i'll begin experimenting in the near future. Hopefully people will comment depending.
Other than all this really, i'm still working on porting Pong and Breakout (i've also thought up names, which i'll try out soon enough.
See you soon.
Friday, 19 June 2009
Another Update
As i'm sure you can guess the Tutorial series is progressing slowly but surely. Its going to be a 12 Part Tutorial at most, so were about half way through.
Aswell as the Tutorial series i'm also working on my own version of the game with a few added features (not too many, but enough). I'm also woring on porting some other "Classic" games aswell. Its quite a long list, but all of the games are fun and familiar to everyone, here's a quick list (not in the right order).
1. Pong
2. Breakout
3. Space Invaders
4. Asteroids
5. Lunar Lander
So i'm currently in Level design mode in Breakout where i'm aiming for atleast 20. As for Pong i'm currently working on final polish and optimisation.
All names are ofcourse due to change, but i'll post proper names as and when they are needed (I haven't thought of them yet :)
So, tune in for the next update!
Saturday, 13 June 2009
Making "Pong" - Part 5
In this part i'll add keyboard input for both "player1" and "player2" allowing them both to move up and down.
Setup...
To begin, open the "Actions - Frame" tab. This is where we will put the code.
Code...
1. speed = 4;
2.
3. player1 = attachMovie("obj_paddle", "obj_paddle", 0);
4. player1._x = 30;
5. player1._y = 200;
6. player1.score = 0;
7.
8. player2 = attachMovie("obj_paddle", "obj_paddle", 1);
9. player2._x = 520;
10. player2._y = 200;
11. player2.score = 0;
12.
13. ball = attachMovie("obj_ball", "obj_ball", 2);
14. ball._x = 275;
15. ball._y = 200;
16. ball.xspeed = -5;
17. ball.yspeed = random(4) - random(4);
18.
19. onEnterFrame = function(){
20.
21. //Ball
22. ball._x += ball.xspeed;
23. ball._y += ball.yspeed;
24.
25. //Player 1
26. if(Key.isDown(87)){
27. player1._y -= speed;
28. }
29.
30. if(Key.isDown(83)){
31. player1. _y += speed;
32. }
33.
34. //Player 2
35. if(Key.isDown(Key.UP)){
36. player2._y -= speed;
37. }
38.
39. if(Key.isDown(Key.DOWN)){
40. player2._y += speed;
41. }
42.
43. }
Explained...
Lines "21", "25" and "34" are comment lines. The compiler will ignore these lines when the program runs. I am using them to seperate the "ball", "player1" and "player2" code.
The "Key.isDown" call is used to access the "Key" class and check whether a Key has been pressed. In the brackets we can specify the keys. For "player1" I use the ASCII code of the key "W" and "S" as the key class doesn't have a definition of these keys, whereas for "player2" I use the predefined keys, "Key.UP" and "Key.DOWN" to check the Up and Down arrow keys.
When a Key has been pressed, the "speed" is either added "+=" or subracted "-=" from the current coordinate allowing the "Paddles" to move. This is very similar to the way the "ball" moves.
Press CTRL + ENTER to run the program.
Next Time...
I'll be adding bounds for both the "players" and "ball" to restrict movement.
Any Questions or Comments?
