PDA

View Full Version : how to scrolling game for 2 (optional)


Babaloo
02-06-2007, 10:52 PM
hey guys!
my first post here, thanks actionscript.org...
I'm coding a scrolling game (a white water challenge) and i'd like to have an optional 2 player (turn-based: after player 1 finishes, player 2 steps in and after that total scores and then game over - or replay).
I'd love any suggestions on initiating players (a button, a variable and then???), tracking scores and game turns!
so this is my prototype for the scrolling background:

//start container bgscroll
_root.attachMovie("scroller","theScroll",10);
// initial scroll position
theScroll._x = Stage.width;
theScroll.onEnterFrame = function(){
var i= - 5;
theScroll._y = 0;
//moving from right 2 left
theScroll._x += i;
};
//attach margin layer
theScroll.attachMovie("margin_scroller","theScrollB",10);
theScroll.theScrollB._y = 88;
theScroll.theScrollB._x = 0;
//attach riverbed layer
theScroll.attachMovie("riverbed_scroller","theScrollA",theScroll.getNextHighestDepth());
theScroll.theScrollA._y = 330;
theScroll.theScrollA._x = 0;

_root.attachMovie("water","theBlue",theScroll.getNextHighestDepth());
theBlue._y = 100;
theBlue._x = 0;


is this newbie? i feel sooo newbie :eek:

thanks for reading!

Babaloo
02-07-2007, 04:54 PM
So I came up with an ingenious formula to my dillema (or so I'm thinking...)
I'm placing 1 and 2 players buttons on the splash screen and each assigns a value to var numPlayers. When the player hits "start" game,
if numPlayers equals 1 then run scrolling MC "x" times but if numPlayers equals 2 then run MC "x" *2 times.
Of course I'll have to keep scores for each player, so i was thinking that if i could tell if the turn was an odd or even turn i could differentiate the players , tracking their scores and so on.

Is this a good approach? Any suggestions, comments? I'm quite excited about my li'l game now...

Babaloo
02-08-2007, 11:17 PM
hmmm the noob saga goes on...
figuring an odd or even number is a breeze really, if you know what a modulo "%" operand is!

like so:

((myNum % 2) == 0) ? trace ("it's even") : trace ("it's odd");
this is from joshbuhler.com :)