Computer Science Canada help with game in flash |
Author: | camilito [ Tue Dec 20, 2005 5:46 pm ] |
Post subject: | help with game in flash |
i need help with my game please. um...well I'm doing this game thats like a monkey jumping game kind of thing. the game is supposed to do, that when it reaches the end of the screen it'll go to the next level, but my game fails to do that and I've tried many things like adding a code layer and doing several hitTest codes. if anyone could help me i'd be very appreciative. i will post the code of my game and if anyone could fix it up I will praise the floor u walk on. i will provide pictures of what it looks like as well just so that u have reference, i wont go too indepth of my game, but ill give you enough information so you know what the basic concept is... ps: im a beginner still so please any code that you add, keep it simple. (im still in gr 10) THIS IS INSIDE THE MONKEY IN FRAME TWO OF LAYER BACKGROUND: onClipEvent (load) { // when the character is loaded var score = 0; speed = 0; // set speed to zero maxmove = 10; //set max movement to 10 jumping = true; // allow jumping jump = 0; // set jump to 0 so that character falls to ground when frame loads } onClipEvent (enterFrame) { // when character enters frame set the following if (_root.dead) { this.gotoAndStop("fraDead"); // go to frame "dead" } else { speed *= .9; if (speed>0) { //when speed is greater than 0 set direction to right dir = "right"; } else if (speed<0) { //when speed is less than 0 set direction to left dir = "left"; } if (dir == "right") { //when direction is right this._x += speed; //move x coordinates of character according to speed } if (dir == "left") { //when direction is left this._x += speed; } if (Key.isDown(Key.LEFT)) { //when left key is pressed if (speed>-maxmove) { speed--; //makes the character move left } this.gotoAndStop("fraRun"); // display running frame this.gotoAndPlay("fraArm1"); //display arm fling frame this.gotoAndPlay("FraArm2"); //display arm fling frame this.gotoAndPlay("fraLeg1"); //display leg fling frame this.gotoAndPlay("fraLeg2"); this._xscale = -50; // flip frame horizontally } else if (Key.isDown(Key.RIGHT)) { //when right key is pressed if (speed<maxmove) { speed++; //makes the character move right } this._xscale = 50; this.gotoAndStop("fraRun"); //display run frame this.gotoAndPlay("fraArm1"); //display arm fling frame this.gotoAndPlay("FraArm2"); //display arm fling frame this.gotoAndPlay("fraLeg1"); //display leg fling frame this.gotoAndPlay("fraLeg2"); //display leg fling frame } else if (speed<1 && speed>-1) { //when speed is greater then -1 and less than one speed equals zero speed = 0; this.gotoAndStop("fraNormal"); //display normal frame state } if (Key.isDown(Key.UP) && !jumping) { // when up key is pressed (declare the action as jumping) jumping = true; // allow jumping } if (jumping) { // when jumping this.gotoAndStop("frajump"); // display jumping frame state this._y -= jump; // change y cooordinates accordingly to the jump jump -= 1.2; //change jump height } if (jump<0) { //when jump reaches its peak, allow falling falling = true; } if (jump<-17) { // bring character back down jump = -17; } } if (this.hitTest(_root.movGround) == true) { // when character touches ground jump = 17; // set jump to full potential again jumping = false; // end jump falling = false; // end falling } if (this.hitTest(_root.movFall) == true) { // when character touches ground jump = -14; // set jump to full potential again jumping = true; // end jump falling = true; // end falling } if (this.hitTest(_root.movGround2)) { // when character touches ground jump = 17; // set jump to full potential again jumping = false; // end jump falling = false; // end falling } if (this.hitTest(_root.movDead)) { // when character touches ground jump = 0; // can't jump anymore jumping = false; // end jump falling = false; // end falling speed = 0; //no more speed maxmove = 0; } } yah thats pretty much all the code u need, a bit of the code are on the pictures...um...yah if could could please help me id really appreacite it... |
Author: | lord_pwnerer [ Wed Nov 08, 2006 9:33 pm ] |
Post subject: | |
Grade is not an excuse. Try using something simpler with your hitTest if you want it to go to another level. For example, why not just making it go to another frame? |