Help With SNAKE Style Game
I am making a game with Flash MX ver 6.0
It is fine so far except i do not know how to make objects appear randomly around the canvas after one another. Like the objects you pick up when playing snake.
I think i should use attachMovie but am not sure .
If anyone knows anything or could show me a tutorial I would greatly appreciate it.
BTW I am not making a tile-based game it is art-based
FlashKit > Flash Help > Flash MX
Posted on: 09-15-2004, 09:10 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Help Snake Game
Hi, if i was trying to make a snake game, how would I go about doing it. I'm not asking for an entire game, but I am kind of stuck. I start out with one segment int the body and it can move fine, but how do I tell the other segments to follow the one before it?
[CS3] Snake Game, Game Size
I'm using this snake game code from the old Nokia phones. The game takes place in a 150X150 square, i want this to be 384X512 but ideally it would be in a var so it can be changed easily. Can anyone help?
PHP Code:
var unit = 15;//size of snake partsvar uwh = 20;//?var canMove = false;var dir = 2;var score = 0;aPieceList = new Array();mouseListener = new Object();mouseListener.onMouseDown = function(){ if (!canMove) { canMove = true; startGame(); }};Mouse.addListener(mouseListener);k = new Object();k.onKeyDown = function(){ var k = Key.getCode(); if (k == Key.UP && dir != 2 && canMove) { dir = 0; canMove = false; } else if (k == Key.LEFT && dir != 3 && canMove) { dir = 1; canMove = false; } else if (k == Key.DOWN && dir != 0 && canMove) { dir = 2; canMove = false; } else if (k == Key.RIGHT && dir != 1 && canMove) { dir = 3; canMove = false; }};Key.addListener(k);function addPiece(){ var p = this.attachMovie("piece", "piece" + aPieceList.length, aPieceList.length); p._x = aPieceList[aPieceList.length - 1]._x; p._y = aPieceList[aPieceList.length - 1]._y; aPieceList.push(p);}function moveFood(){ var moveIt = true; while (moveIt) { food._x = Math.floor(Math.random() * uwh) * unit; food._y = Math.floor(Math.random() * uwh) * unit; moveIt = false; for (var i = 0; i < aPieceList.length; i++) { if (aPieceList[i]._x == food._x && aPieceList[i]._y == food._y) { moveIt = true; } } }}function gameOver(){ delete this.onEnterFrame; tScore.text = "You Lose. Score: " + score; canMove = false;}function startGame(){ for (var i = aPieceList.length - 1; i >= 0; i--) { aPieceList[i].removeMovieClip(); aPieceList.pop(); } score = 0; var p = this.attachMovie("piece", "piece" + aPieceList.length, aPieceList.length); aPieceList.push(p); p._x = 10 * unit; p._y = 10 * unit; var food = this.attachMovie("food", "food", -1); var c = 0; moveFood(); var startingLength = 3; for (var i = 1; i < startingLength; i++) { addPiece(); } this.onEnterFrame = function() { canMove = true; tScore.text = score; for (var i = aPieceList.length - 1; i > 0; i--) { aPieceList[i]._x = aPieceList[i - 1]._x; aPieceList[i]._y = aPieceList[i - 1]._y; } if (dir == 0) { aPieceList[0]._y -= unit; } else if (dir == 1) { aPieceList[0]._x -= unit; } else if (dir == 2) { aPieceList[0]._y += unit; } else if (dir == 3) { aPieceList[0]._x += unit; } if (aPieceList[0]._y / unit == 20) { aPieceList[0]._y = 0; } else if (aPieceList[0]._y / unit == -1) { aPieceList[0]._y = 19 * unit; } else if (aPieceList[0]._x / unit == -1) { aPieceList[0]._x = 19 * unit; } else if (aPieceList[0]._x / unit == 20) { aPieceList[0]._x = 0; } if (aPieceList[0]._x == food._x && aPieceList[0]._y == food._y) { score += 10 * aPieceList.length / 2; moveFood(); addPiece(); } for (var i = 1; i < aPieceList.length; i++) { if (aPieceList[0]._x == aPieceList[i]._x && aPieceList[0]._y == aPieceList[i]._y) { gameOver(); } } };}
Worm Or Snake Game
I am trying to make my own worm game but I am stuck.
If somebody has a code for it Please sent it to t0mc4thr@yahoo.com
thanks
Snake Game Problems
I'm creating a snake-like game but I just ran into some problems. (It's a game where the snake has to continously grow, so that the tail stays and the body just gets longer and longer.)
In my game the snake has a head that moves, and a body-mc that is beeing duplicated and places behind the head every time it moves.
The problem is that the body isn't beeing duplicated. The head IS moving but the body doesn't grow. I think it has something to do whith the DuplicateMovieClip script and the variables in it. Can someone please help me?!
I think the script was a little to long to post here, and that you have to se the whole file. I have attached the .fla-file.
- Hommer
Snake Game Movement Help
I attached the file, basically i need to have the movement eased. Like when the snake goes up and left the square that is turning needs to go to frame 11...
I figure this needs to be adited...
ActionScript Code:
this.onEnterFrame = function() {
canMove = true;
/* Move the snake */
for (var i = aPieceList.length-1; i>0; i--) {
aPieceList[i]._x = aPieceList[i-1]._x;
aPieceList[i]._y = aPieceList[i-1]._y;
if (i != (aPieceList.length-1)) {
if (aPieceList[i-1]._currentframe == 1 or aPieceList[i-1]._currentframe == 3) {
aPieceList[i].gotoAndStop(5);
} else if (aPieceList[i-1]._currentframe == 2 or aPieceList[i-1]._currentframe == 4) {
aPieceList[i].gotoAndStop(6);
} else {
aPieceList[i].gotoAndStop(aPieceList[i-1]._currentframe);
}
}
}
But i can make it work....
I attached the fla... If someone could help i'd greatly appriciate it.
Thank you for your time
~Gabor
Snake Game Problems
I'm creating a snake-like game but I just ran into some problems. (It's a game where the snake has to continously grow, so that the tail stays and the body just gets longer and longer.)
In my game the snake has a head that moves, and a body-mc that is beeing duplicated and placed behind the head every time it moves.
The problem is that the body isn't beeing duplicated. The head IS moving but the body doesn't grow. I think it has something to do whith the DuplicateMovieClip script and the variables in it. Can someone please help me?!
I think the script was a little to long to post here, and that you have to se the whole file. I have attached the .fla-file.
- Hommer
Snake Game Problem...
I cant figure out whats wrong....and its making me mad. lol. anyways, its a basic snake game within a box...hit the wall, ur done...simple. But my top wall isn't working properly and the character goes right off the scene....and it keeps going....and going....and going. Any help would be appreciated. Unfortuantly, I cant upload anything because its too big....
Map Editor For Snake Game
Hello All.
It was a while back that I made this .fla, but I don't know what happened, just one day it stopped doing anything when I opened it. The highlight of the file is the Map Editor which if you click around in the box, you will see the program insert little boxes in which serve as walls for the game. But as I mentioned, the file does not even really open. When I select it and tell Flash to open it, it acts like it is opening it, but does not do anything... Does anyone know what the problem may be?
Also, Flash seriously and litterally will open up any of my other .flas except this one... If anyone can open the file, could they save it as something else and send it back to me as I really want to continue working on the file, but I don't want to start back over again as it took me a while to get to where I am in the program.
Thanks for Everyone's Help
Snake Game Problems
I'm creating a snake-like game but I just ran into some problems. (It's a game where the snake has to continously grow, so that the tail stays and the body just gets longer and longer.)
In my game the snake has a head that moves, and a body-mc that is beeing duplicated and placed behind the head every time it moves.
The problem is that the body isn't beeing duplicated. The head IS moving but the body doesn't grow. I think it has something to do whith the DuplicateMovieClip script and the variables in it. Can someone please help me?!
I think the script was a little to long to post here, and that you have to se the whole file. I have attached the .fla-file.
- Hommer
Snake Game Problem...
I cant figure out whats wrong....and its making me mad. lol. anyways, its a basic snake game within a box...hit the wall, ur done...simple. But my top wall isn't working properly and the character goes right off the scene....and it keeps going....and going....and going. Any help would be appreciated. Unfortuantly, I cant upload anything because its too big....
Advanced Snake Game (giving Me A Big Headache...)
(mx)
Hi all,
I don't know if this is even possible, but i don't want to give up yet.
A client want's me to do a "snake"style game BUT the head, the torso and the tail are made of different graphics (different in style, color, shape) which means I can't use the engines from here, because they are all made for snakes that consist of the same rectangular shapes (adding and removing clips as needed)
since in the game i have to do, the head for example is 10 by 15 px in size and resembles a horse, i have to rotate it when it changes directions, which is really not a big issue, but i have to somehow save the position where it changed directions, because the following objects have to change directions and rotations at the same spot.
........
if anyone has a cool idea on this, please let me know
thanks in advance
[Game] - Curvy Snake - 2minute Jobby
Yeah, You've all seen snake a-la nokia, grid n'all, well, got asked to do a version, WHY ME? poor game, so I've added a little spice, (er, well a curvynature)
play it here - haven't touched the GFX yet, lol!, but criticisma s to making harder/better always wanted...
D&D Style Game Engine
ok, i've been workin on the engine for a D&D style rpg. I've come across a problem that I, as usual, don't know how to fix because it appears right to me. I've tried everything under the small yet slowly expanding sun that is my actionscript knowledge.
concept
player presses attack button. Actionscript runs formula to determine if attack is successful or not. If player fails the computer (bad guy) takes its turn. If the player is successful she is then prompted to press the "roll damage dice" button to determine damage.
problem
the "roll damage" button won't do what its supposed to. When the player presses the attack button, it changes a variable called "turn" depending on the outcome. If the hitRoll is less than hitDice, the hit fails and turn=3...the bad guy's turn. If hitRoll is greater than or equal to hitDice then turn=2...roll damage dice. So i put code on the damage button that says if turn=2, do all this stuff else .enabled=false. If turn=3, .enabled=false. But the problem is this: the damage button is always enabled. if you "roll" less than hitDice you not supposed to be able to press the damage button, but it works anyway. In other words, the only time the damage button should work is if hitRoll is greater than or equal to hitDice thus making turn=2.
Code:
//on main timeline (actions layer) to determine value of "turn"
if(heroHitRoll >= heroHitDice){
turn=2;
}else{
turn=3;
}
//note: originally this code was on the attack button
Code:
//on damage button
on(release){
if(_root.turn=2){
if(_root.heroDmgRoll=0){
dmgBTN.enabled;
}else{
dmgBTN.enabled=false;
}
_root.heroDmgRoll=_root.hero.dmg+_root.hero.dmgRollB;
}else if(_root.turn=3){
dmgBTN.enabled=false;
}
}
I've included the fla. Help please!!
-::: Game - Kick Up Style :::-
Hi everyone.
Could anyone help me make a game?
Bascally i want to make a game like Pong or break out. Where you have the rectangle at the bottom of the screen. The ball drops down. The player moves the rectangle left and right to deflect the ball. The ball bounces off of the roof and back down where the player rebounds it again.
This is the general idea anyway....
Can anyone help me make this...thanks very very much
All the best
How To Use Hit Test - For Ff Style Game
I am trying to code a very basic side scrolling beat em up, however I am having problems with the hit detection, in the heros onClip(enter) i have included the following code
for(i=1;i<=_root.numEnemy;i++)
{
if(this.hitTest(_root["enemy"+i]))
{//Hit test for knack 1
_root.score+=25;
_root["enemy"+i].enemyLife-=40;
_root["enemy"+i]._x-=25;
_root["enemy"+i].gotoAndStop("hit");
}
}
in the enemy's onclip(enter) i included the code below
if(this.hitTest(_root.hero))
{//Enemy attacks
this.gotoAndStop("strike");
_root.hero.gotoAndStop("hit");
//_root.hero.health-=10;
}
However the problem is that when I run or debug it the movie never enters the for loop in the heros code and so the hero is always hit by the enemy and is unable to hit them, any suggestions on how to resolve this would be welcome, a sceondary issue which I would also appreciate any comments on is how could i set it up so that it only counts as a hit if just the fist portion of the hero animation connects with the enemys graphic ?
Game-Style Scrolling BG
hey folks ... i'm new to this forum, but not new to FlashKit.
my friend is making a game in flash. it's a side-scrolling game with an animated main character.
my question is, he can't figure out how to script the background in such a way that the background scrolls with his character correctly both ways ... thus far he can press the right arrow key, and have the character "run" right by scrolling the background to the right ... his problem is, he can't figure out how to get the background to scroll properly the other way when he hits the left arrow key, and stop at the end of both sides of the background.
i don't know how well i've phrased that, but i did my best ... any ideas would be greatly appreciated.
FFVII Style Map/game
hey guys i need some help and im not sure how to go about this.
im wanting to do somthing like FFVII for an assignment i have to do.
i dont want the battlesystem but just the map thing with a character and walk around in a sudo 3D environment.
and be able to interact with things.
(interact as in like press space bar and it opens a small dialog box)
i can probably make the character in all the states. facing in 8 directions with walking animation
so im guessing you make that MC but then how would you make him run around by pressing the direction buttons and then face the right way.
then i need to know how to stop him so he cant walk out of the map. so walls stop him. and he cant walk through trees. etc.
and how would you make it to the character MC can interact with other MCs in the map.
any help would be much appreciated
i would really love to get this done.
edit: ok i decided i will only need 4 states for the character: up,down,left and right
and can use this code
Quote:
onClipEvent (load) {
moveSpeed = 19;
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT)) {
this._x += moveSpeed;
} else if (Key.isDown (Key.UP)) {
this._y -= moveSpeed;
} else if (Key.isDown (Key.DOWN)) {
this._y += moveSpeed;
} else if (Key.isDown (Key.LEFT)) {
this._x -= moveSpeed;
}
}
right?
what about collision detection.
can i assign that to a layer. and just color in or place objects with a code saying the character cant walk here then make this layer invisible
[F8] Beat Em Up Style Of Game
You know when you move up and down, the player switches depth with the enemy? How is it possible to do this? I have tried several experiments but they come out badly.
[F8] Starfield-style Game
Hey, I'm having trouble making a game, and I cant seem to get something working. Here is what I have so far:
http://school.timswildwackyemporium....st/candy1.html
As you can see, When you play Once you catch the stars, they disappear.
As a result, the highest score you can get is one hundred.
I would like to make it so that rather than just delete the movieclip, I can movie it back into the beginning of the starfield.
I did not write the code for the starfield, which is why I'm having such trouble figuring this out.
Heres my code
ON THE FRAME
Code:
stop();
score = 0 ;
_root.attachMovie("count_down", "count_down", 12000, {_x:20, _y:330});
_root.attachMovie("hero", "hero_on_stage", 10000,{_x:200,_y:20});
_root.attachMovie("trail_sprite", "trail_mc", 8000);
trailbitmap = new flash.display.BitmapData(500, 350, true,0x000000);
_root.createEmptyMovieClip("trail", 1);
trail.attachBitmap(trailbitmap, 0);
trail_mc._visible = false;
hero_on_stage._visible = false;
power = .65;
yspeed = 0;
xspeed = 0;
wind = 0.00;
gravity = 0;
upconstant = 0.75;
friction = 0.99;
start_time = getTimer();
countdown = 30000;
hero_on_stage.onEnterFrame = function() {
elapsed_time = getTimer()-start_time;
_root.count_down.time_left.text = time_to_string(_root.countdown-elapsed_time);
if (elapsed_time >= countdown) {
_root.gotoAndStop(5);
_root.count_down.removeMovieClip();
};
if (Key.isDown(Key.LEFT)) {
xspeed = xspeed-power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed = xspeed+power;
}
if (Key.isDown(Key.UP)) {
yspeed = yspeed-power*upconstant;
}
if (Key.isDown(Key.DOWN)) {
yspeed = yspeed+power*upconstant;
}
xspeed = (xspeed+wind)*friction;
yspeed = yspeed+gravity;
if (xspeed>15) {
xspeed = 15;
}
if (xspeed<-15) {
xspeed = -15;
}
if (yspeed>15) {
yspeed = 15;
}
if (yspeed<-15) {
yspeed = -15;
}
this._y += yspeed;
this._x += xspeed;
if (this._x<0) {
this._x += 500;
}
if (this._y<0) {
this._y += 350;
}
if (this._y>350) {
this._y -= 350;
}
if (this._x>500) {
this._x -= 500;
}
_root.trail_mc.trail_sprite._x = this._x;
_root.trail_mc.trail_sprite._y = this._y;
_root.trailbitmap.draw(_root.trail_mc);
trail_rectangle = new flash.geom.Rectangle(0, 0, 500, 350);
trail_blur = new flash.filters.BlurFilter(2, 2, 3);
_root.trailbitmap.applyFilter(_root.trailbitmap, trail_rectangle, new Point(0, 0), trail_blur);
};
MovieClip.prototype.placeInSpace = function(id) {
var ratio = this.focaldistance / Math.sqrt(this[id].z * this[id].z);
this[id]._x = this[id].x * ratio;
this[id]._y = this[id].y * ratio;
this[id]._xscale = this[id]._yscale = 1000 / this[id].z;
if (this[id].hitTest(hero_on_stage)){
_root.score ++;
this[id].swapDepths(10000);
this[id].removeMovieClip();
}
}
MovieClip.prototype.randomPlace = function(id) {
var radius = this.rmin + (this.rmax - this.rmin) * Math.random();
var polar = 2 * Math.PI * Math.random();
this[id].x = radius * Math.cos(polar);
this[id].y = radius * Math.sin(polar);
this[id].z = this.zmin + (this.zmax - this.zmin) * Math.random();
if (this[id].hitTest(hero_on_stage)){
_root.score ++;
this[id].removeMovieClip();
}
}
function time_to_string(time_to_convert) {
elapsed_hours = Math.floor(time_to_convert/3600000);
remaining = time_to_convert-(elapsed_hours*3600000);
elapsed_minutes = Math.floor(remaining/60000);
remaining = remaining-(elapsed_minutes*60000);
elapsed_seconds = Math.floor(remaining/1000);
remaining = remaining-(elapsed_seconds*1000);
elapsed_fs = Math.floor(remaining/10);
if (elapsed_hours<10) {
hours = "0"+elapsed_hours.toString();
} else {
hours = elapsed_hours.toString();
}
if (elapsed_minutes<10) {
minutes = "0"+elapsed_minutes.toString();
} else {
minutes = elapsed_minutes.toString();
}
if (elapsed_seconds<10) {
seconds = "0"+elapsed_seconds.toString();
} else {
seconds = elapsed_seconds.toString();
}
if (elapsed_fs<10) {
hundredths = "0"+elapsed_fs.toString();
} else {
hundredths = elapsed_fs.toString();
}
return minutes+":"+seconds+":"+hundredths;
}
ON THE STARFIELD MOVIECLIP
Code:
onClipEvent (load) {
this.count = 100;
this.speed = 3;
this.focaldistance = 25;
this.rmin = 50;
this.rmax = 1000;
this.zmin = 10;
this.zmax = 300;
for(var i = 0; i < this.count; i++) this.attachMovie("dot", i, i);
}
onClipEvent (enterFrame) {
for(var i = 0; i < this.count; i++) {
if((this[i].z -= this.speed) <= 0) this.randomPlace(i);
this.placeInSpace(i);
}
Hotwire Style Game Help
Hello. For part of my project i need to create a little mini-game based on hot wiring a car. I need a selection of wires on each side of the screen, and when the correct 2 touch, then it will skip onto the next frame. Any ideas how i might be able to do this??
Cheers
Andy
Pacman Style Game Help
Hi all, I'm new to flash and I'm making my own version of pacman just so that I can learn a bit more about actionscript. I'm having a problem with the collision detection, I can get the player to stop when he hits one wall from all directions, but another instance of that wall with the same instance name will not stop the player at all? I'm very puzzled as I cannot see why it is happening. I have uploaded the .fla file and if anyone could help me it would be greatly apprectiated. Thanks.
Jeopardy-Style Game Question
I have created a Jeopardy-style game for an online learning course.
Each choice (i.e., people for 100, etc...) is a button. How do I get the buttons to disapear after they are clicked once?
Really Stuck, Pong Style Game.
hi, im having a little trouble doing a little actionscript, what i am doing is sort of like a pong game.
i was wanting to make the ball go up and down, top to bottom, rather than the usual left to right pong game,
i have attached a cut version of the game i am making incase you dont understand this drible i am writing.
i have no trouble making it go left and right like the standard pong game.
so the bottom line is, i need to make the ball go up and down and add 1 to the score when it passes the top bat or the bottom bat, also the bats need to move left to right and hit the ball etc...
i really dont know why i cant do it as i said i can make it all work going horizontal, but vertical as been a real challenge, so i needed help.
many thanks,
Ben
p.s. ive taken the background out and the preloader etc, to save on upload download time, this is why it is called cutversion
Help On Making Boxing-style Game
I am basically trying to make a boxing-style game from the first-person point of view. The cursor will be fists, and when you click on the opponent, the fists will swing. When you click, it will randomly decide whether it should be a right hook, left hook, or uppercut. Upon striking the enemy, it will take you to a new frame where the enemy is injured(ie. blood, bruises), and the health bar will decrease. The enemy will not fight back in this one.
[MX] Flash Game Keno Style
Hi everyone,
I am fairly new to ActionScript and Flash, and I am developing a flash game. Basically I have a script that picks x number of random numbers (between 1-72) and displays them in a text box. My next step is to layout a numbered board from 1-72 and then display an "X" or something similar to each number that was chosen - hence keno style. I am a little lost on how to approach this an am asking for a little direction and possible solutions. Any ideas?
Here is my code from my "scripts" layer:
code:
stop();
//Scripts file for all functions//
var pickNumber = numberPick;//VARIABLE FROM INPUT BOX//
// Choose x numbers from a list of y numbers (ranging from 1 - x-1)
x = 73;
y = pickNumber;
myArray = [];
///////////////////////////////////////////
for (i = 1; i < x && y > 0; ++i) {
if (random(x-i) < y) {
myArray.push(i);
y--;
}
}
///////////////////////////////////////////
[F8] Help With Alien Invader Style Game...
I can't figure out why my hit test wont work... I am really new to actionscript so if you could talk to me like I am an infant it would be great!
stop();
this.hitText._visible = false;
this.defender.onEnterFrame = function() {
defenderSpeed = 10;
if (Key.isDown(Key.RIGHT)) {
this._x += defenderSpeed;
}
if (Key.isDown(Key.LEFT)) {
this._x -= defenderSpeed;
}
};
bullet.onEnterFrame = function() {
if (Key.isDown(Key.SPACE)) {
this.gotoAndPlay("shot");
}
};
bullet.onEnterFrame = function() {
if (alien.hitTest(10, 10, true)) {
hitText.text = "You Saved The World!";
this.gotoAndPlay("boom");
hitText._visible = true;
alien.onEnterFrame = function() {
alienSpeed = 10;
alien._x = random(0);
alien._y = random(0);
};
thanks
james
MySpace Advert Style Game
I want to make a small and basic flash game in the style of those adverts on myspace.
The ones that are essentially link banners but as soon as you rollover them with your cursor, they act as a game. Such as you cursor turns into a crosshair and you have to shoot aliens and stuff. Or you have to click on the running cat or whatever.
I've looked for a while and cannot find a file from which to learn.
Does anyone know of some code where I can learn from ?
Thanks to all in advance.
Koit
Deccelerate And Accelerate (Game Style)
Trying to make an object accelerate when i press UP and deccelerate when pressing DOWN. Ive used var i as a test and a dynamic text field that displays i. so i want i to subtract as long as UP is not pressed and add when UP is pressed.
this is what i tried, but it didnt work.
PHP Code:
i = 10;
var myKeyListener:Object = new Object();
Key.addListener(myKeyListener);
myKeyListener.onKeyDown = function() {
if (Key.getCode() == Key.UP) {
i++;
}else{i--;}
};
Pacman Style Game Problem
i have made my first lvl for a pacman style game.
on the first frame i have my intro movie (in an mc) and on the second frame i have my first level with my charecter on it. this works fine but on my third frame i made a second level and copyed my charecter onto it but thee charecter cannot move, he only turns.
this is the actionscript on my charecter:
ActionScript Code:
onClipEvent (load) {
moveSpeed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
gotoAndStop (1);
} else if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
gotoAndStop (2);
} else if (Key.isDown(Key.UP)) {
this._y -= moveSpeed;
gotoAndStop (3);
} else if (Key.isDown(Key.DOWN)) {
this._y += moveSpeed;
gotoAndStop (4);
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall1)) {
_y = _y-5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall2)) {
_y = _y+5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall3)) {
_x = _x+5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall4)) {
_y = _y-5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall5)) {
_x = _x-5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall6)) {
_x = _x-5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall7)) {
_y = _y-5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall8)) {
_x = _x+5;
}
}
onClipEvent (enterFrame) {
if (this.hitTest(this._parent.wall9)) {
_y = _y+5;
}
please help me!
any help would be greatly appreciated
Starfield Style HitTest Game
Hey, I'm having trouble making a game, and I cant seem to get something working. Here is what I have so far:
http://school.timswildwackyemporium....st/candy1.html
As you can see, When you play Once you catch the stars, they disappear.
As a result, the highest score you can get is one hundred.
I would like to make it so that rather than just delete the movieclip, I can movie it back into the beginning of the starfield.
I did not write the code for the starfield, which is why I'm having such trouble figuring this out.
Heres my code
ON THE FRAME
Code:
stop();
score = 0 ;
_root.attachMovie("count_down", "count_down", 12000, {_x:20, _y:330});
_root.attachMovie("hero", "hero_on_stage", 10000,{_x:200,_y:20});
_root.attachMovie("trail_sprite", "trail_mc", 8000);
trailbitmap = new flash.display.BitmapData(500, 350, true,0x000000);
_root.createEmptyMovieClip("trail", 1);
trail.attachBitmap(trailbitmap, 0);
trail_mc._visible = false;
hero_on_stage._visible = false;
power = .65;
yspeed = 0;
xspeed = 0;
wind = 0.00;
gravity = 0;
upconstant = 0.75;
friction = 0.99;
start_time = getTimer();
countdown = 30000;
hero_on_stage.onEnterFrame = function() {
elapsed_time = getTimer()-start_time;
_root.count_down.time_left.text = time_to_string(_root.countdown-elapsed_time);
if (elapsed_time >= countdown) {
_root.gotoAndStop(5);
_root.count_down.removeMovieClip();
};
if (Key.isDown(Key.LEFT)) {
xspeed = xspeed-power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed = xspeed+power;
}
if (Key.isDown(Key.UP)) {
yspeed = yspeed-power*upconstant;
}
if (Key.isDown(Key.DOWN)) {
yspeed = yspeed+power*upconstant;
}
xspeed = (xspeed+wind)*friction;
yspeed = yspeed+gravity;
if (xspeed>15) {
xspeed = 15;
}
if (xspeed<-15) {
xspeed = -15;
}
if (yspeed>15) {
yspeed = 15;
}
if (yspeed<-15) {
yspeed = -15;
}
this._y += yspeed;
this._x += xspeed;
if (this._x<0) {
this._x += 500;
}
if (this._y<0) {
this._y += 350;
}
if (this._y>350) {
this._y -= 350;
}
if (this._x>500) {
this._x -= 500;
}
_root.trail_mc.trail_sprite._x = this._x;
_root.trail_mc.trail_sprite._y = this._y;
_root.trailbitmap.draw(_root.trail_mc);
trail_rectangle = new flash.geom.Rectangle(0, 0, 500, 350);
trail_blur = new flash.filters.BlurFilter(2, 2, 3);
_root.trailbitmap.applyFilter(_root.trailbitmap, trail_rectangle, new Point(0, 0), trail_blur);
};
MovieClip.prototype.placeInSpace = function(id) {
var ratio = this.focaldistance / Math.sqrt(this[id].z * this[id].z);
this[id]._x = this[id].x * ratio;
this[id]._y = this[id].y * ratio;
this[id]._xscale = this[id]._yscale = 1000 / this[id].z;
if (this[id].hitTest(hero_on_stage)){
_root.score ++;
this[id].swapDepths(10000);
this[id].removeMovieClip();
}
}
MovieClip.prototype.randomPlace = function(id) {
var radius = this.rmin + (this.rmax - this.rmin) * Math.random();
var polar = 2 * Math.PI * Math.random();
this[id].x = radius * Math.cos(polar);
this[id].y = radius * Math.sin(polar);
this[id].z = this.zmin + (this.zmax - this.zmin) * Math.random();
if (this[id].hitTest(hero_on_stage)){
_root.score ++;
this[id].removeMovieClip();
}
}
function time_to_string(time_to_convert) {
elapsed_hours = Math.floor(time_to_convert/3600000);
remaining = time_to_convert-(elapsed_hours*3600000);
elapsed_minutes = Math.floor(remaining/60000);
remaining = remaining-(elapsed_minutes*60000);
elapsed_seconds = Math.floor(remaining/1000);
remaining = remaining-(elapsed_seconds*1000);
elapsed_fs = Math.floor(remaining/10);
if (elapsed_hours<10) {
hours = "0"+elapsed_hours.toString();
} else {
hours = elapsed_hours.toString();
}
if (elapsed_minutes<10) {
minutes = "0"+elapsed_minutes.toString();
} else {
minutes = elapsed_minutes.toString();
}
if (elapsed_seconds<10) {
seconds = "0"+elapsed_seconds.toString();
} else {
seconds = elapsed_seconds.toString();
}
if (elapsed_fs<10) {
hundredths = "0"+elapsed_fs.toString();
} else {
hundredths = elapsed_fs.toString();
}
return minutes+":"+seconds+":"+hundredths;
}
ON FIELD MOVIECLIP
Code:
onClipEvent (load) {
this.count = 100;
this.speed = 3;
this.focaldistance = 25;
this.rmin = 50;
this.rmax = 1000;
this.zmin = 10;
this.zmax = 300;
for(var i = 0; i < this.count; i++) this.attachMovie("dot", i, i);
}
onClipEvent (enterFrame) {
for(var i = 0; i < this.count; i++) {
if((this[i].z -= this.speed) <= 0) this.randomPlace(i);
this.placeInSpace(i);
}
Help With A Gta Style Birdseye Game-shooting
basically i have a game in the making and im in need of some help with making my guy shoot, i allready have him running around with the map scrolling and i have him able to aim his gun with mouse detection.
basically my next step is to give him the ability to shoot his gun
and then to add walls around the map
can anyone help with these?
any help is greatful!
heres the demo file:
http://img.photobucket.com/albums/v1...enginegame.swf
Gta Style Game: Skid Marks
Hey all, I'm making a GTA style game and I'm trying to do the skidmarks. I have no idea how to do this, I heard talk about using the action scripting to draw lines but all I've seen it do id draw straight lines. Any ideas how to do this. I'll post up my .fla if its necessary.
Rpg (tank) Style Game. VS Interface Help Please
Hi people!!!
Im having a big trouble here, and I only have about 25 days to got it. Im trying to make a simple (or complex) tank game, You know, that game where you can create scenearies and you must protect a silver eagle from the enemie tanks attack. Ok. Kirupa Tutorials has helped me a lot creating the graphic interface and programming movements and HitTesting using bidimensional arrays.
Now, the big problem is make a network versus interface. You know, the 2 players mode, but players using different terminals. I need alot of info programming this, and the necessary connections, ports...everything...
I have not too much time....I need to work hard, and I know, with your help, itll be easier!
Thanks a lot!!!
:::::goto():::::
Gta Style Game: Skid Marks
Hey all, I'm making a GTA style game and I'm trying to do the skidmarks. I have no idea how to do this, I heard talk about using the action scripting to draw lines but all I've seen it do id draw straight lines. Any ideas how to do this. I'll post up my .fla if its necessary.
Habbo Hotel Style Game
Hi, is there anyway you can make a game like habbo hotel in flash??
If so, what software do i need?
And how would i make the people move round to different squares??
e.g.
5x5 grid, you click a square and your person walks over to it. any ideas on this??
Any ideas??
Regards,
Martin
Computing Help And Info:
http://www.webrevolt.biz
Donkey Kong Style Game
Hi all,
I've been trying to get into more game programming recently, and one of my friends asked me about creating a donkey kong game.
For the few in the world unfamiliar with Donkey Kong here:
http://www.donkeykongonline.com/donk...line-game.html
The object of the game is to climb up the ladders to rescue the princess from a giant ape rolling barrels down at you that you have to jump over.
Now, I would never be so stupid as to ask someone to build this for me or even worse have a fully made tutorial on donkey kong, the odds of either are astronomical, plus that would take a lot of the fun out of building.
What I'm curious is if anyone knows of a good tutorial on creating aspects of this game. Such as walking up diagonally to get to DK. Thats one of the things thats stumping me at the moment, that plus getting the barrels to fall at that same angle, but sometimes come down the ladders like they do in the old game.
Then there are odd things link the fire chasing up after you.
Again, I'm not asking anyone to do this for me or anything like that, I'm just looking for some pieces. I've read a few tutorials/articles on side scrollers, but they don't really deal with diagonal movement.
Thank you in advance.
Game Style Website; Character Left And Right
Hi guys,
I really need some help with a code for a website I am developing - i thought i could avoid the issue but it has made it way too complicated and im sure someone will know the answer on here!
Basically, i have my stage and i have a long background image that only a small percentage is visable in the stage area at any one time. I have a character who i want to walk left and right and when the character gets infront of certain things on this background image i would like to hit enter or up and for a movie clip to play overlaying the background image, which will load the text for that link. Does anyone have anyidea the actionscripting i would need for this? The character barely needs to move - the background is what should scroll left and right when the keys are pressed....
I would REALLY appreciate any help at all.
Thankyou!
Help Needed With Crimson Room Style Game.
Can someone please tell me how to achieve the following things:
~Click'n'add inventory
~Movie Clips that stay the same even when you leave the room and come back.
~Pop-Up Windows
Is there anyone who can tell me how to do any of these things?
[F8] Several Problems Trying To Create An Asteroids-style Game
I'm trying to make a game based on the classic "Asteroids" for Atari.
I'm using Flash Professional 8, but coding in AS1 (from various tutorials) and saving as Flash MX 2004 (Since I take it with me to school, and want it to work on the computers there.)
I've got ship movement down, thus far, and collision detection is starting to take shape. However, I am having problems figuring out how to do the following things:
1. Creating random movement for the asteroids
- I don't know what to do with the code I have to make them start by moving in one random direction and then continuing on in that direction. All I can do is make all of them go in the same general direction, at random speeds. So they're either all going up and right, up and left, down and left, or down and right.
2. Causing the original "Asteroid" object to properly end the game when the ship hits it.
- As is, I have one Asteroid, which uses this code;
numEnemy = (3);
for (i=2; i<=numEnemy; i++) {
Asteroid01.duplicateMovieClip("Asteroid"+i, i+300);
}
to duplicate several other asteroids in the scene (defined by the value numEnemy.) If you hit any of the other asteroids, you blow up and the game ends. But for some reason, hitting the one asteroid will only cause it to blow up, not you, and the game does not end. I can't really figure out why this is happening. Also, if you do die, the original asteroid, if it's still on the screen, will continue flying around over the game over screen as if it doesn't have any stop action applied to it.
3. Finally, I need some help figuring out how to make it so the asteroids do not spawn near or on top of the player at the beginning of the game, because that's no fun :P
Any help on any of these issues would be appreciated. I have attached the file so you can mess with it and tell me what I'm doing wrong!
Thanks in advance!
-Pakorn
Clearing A Reversi Style Game Board
I have a reversi style gameboard, i.e. grid where objects can be placed with the mouse as desired.
At the end of the level, I'd like to completely wipe the board before initialising the next level.
Is it possible to do a quick wipe of the board without removing other board elements (like a power metre and buttons) which are movie clips themselves??
Do I need to remove each unit individually with it's unique name?? Or is there a way to do a quick wipe??
Thanks
Thomo
'Stepmania' Style Christmas Game - Please Test
With a little coding help from clbeech, here's my company's annual Christmas offering. It's not entirely finished (I have to slot in a form at the end for high score submissions, plus they're asking for some random speech, etc) but it's very close!
http://strangelydrawn.com/game/santa.html
I'd appreciate a few testers to see if it's a) cheatable or b) breakable. How does it run on your machines? Does the music stay in synch with the game?
Much appreciated, thankyou :)
Jim
How To Make Your Own DEFEND YOUR CASTLE Style Game
A lot of you should know the famous game called 'Defend Your Castle'. if not, then go search it up on Google (or whatever search engine you use)!
You might think that it will be tough, but it's not really!
This is how you do it:
1. Create your flash document (optional... well... you have to make one to edit one!)
2. Make (suprise) a Movie Clip. This will be the person.
3. Double click on the MC (and wait for Flash to get into the MC if you use Windows Vista)
4. Make two frames
5. On the first frame, make a movie clip with your character running. On the other, your character dieing.
6. Label the first frame 'run' and the other 'die'.
7. Give both frames the action 'stop'.
8. Now exit the MC (so there's only 'Scene 1' shown at the top).
9. Give the MC the instance name 'enemy' (no 's)
10. Now give it this code:
on (release) {
gotoAndPlay ("die");
}
This will take your character to the 'die' frame when clicked on.
11. Now (on a new layer) draw the castle (it doesn't have to be a castle... it can be anything you want!).
12. Now tween your guy over from one side of the stage to the object you just drew.
13. Now (on another new layer) make a static text box and write 'Score' (or whatever. It doesn't have to be score. It can be 'points' or 'Kill count'. Don't add the 's though).
14. now make a dynamic text box and type '0' (no 's again). Make sure the alignment is in the middle.
15. Now add this code at the start frame of the 'die' MC (in the 'enemy' MC):
_root.score.text++;
This adds a point to the score/kill count chart.
Finally, give the dynamic text box the instance name 'score' (once again, no 's).
Soz i don't know how to do a health count. Maybe another time!
Now test your movie. Hooray! You now have a 'Defend Your Castle' style game!
if you want to see mine, go to swfup.com -> groups -> Invasion. It's there (make sure the author is called Raffi_Stick)
P.S. I'm new here, and this is my first post, so don't be too harsh.
Memory Style Game - Creating Tile Blocker
I have sample code written like this:
(from "Flash MX 2004:Game Programming" by Murray and Everett-CHurch)
Referencing a memory style game using only 16 tiles. The author notes that they can use the 100 because they are only using 16 tiles.
attachMovie("tile blocker", "blocker"+i+j, tile_depth+100);
blocker_array[i][j] = this ["blocker" +i+j];
He states to organize the tiles into 'Empty Movie Clips" so their depths will be local?
I am not clear on how this would look. I am hoping to create a multilple level memory-style game with at least 20 (or up to 32) tiles per level.
How do I remedy the 100 statement?
Please suggest a reference (and I'll research more) or post a helpful hint
I am looking to learn this better, so I am willing to do a little more leg work -just not certain where to begin to narrow my search and avoid more information than I am ready for.
Thank you
[MX04] Applying Friction To A Scroller Style Game?
I'm quite new to flash. but i've been doing it for a wile (on and off).
I've decided to make a game i have been wanting to make for a wile now.. and
its kind of a side scroller.
i have this for the movement..
Code:
onClipEvent (load) {
speed = 6;
radius = 9;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= speed;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
}
if (Key.isDown(Key.UP)) {
_y -= speed;
}
if (Key.isDown(Key.DOWN)) {
_y += speed;
}
while (_root.wall.hitTest(_x, _y+radius, true)) {
_y--;
}
while (_root.wall.hitTest(_x, _y-radius, true)) {
_y++;
}
while (_root.wall.hitTest(_x-radius, _y, true)) {
_x++;
}
while (_root.wall.hitTest(_x+radius, _y, true)) {
_x--;
}
}
i was wondering how i could add friction to this. so that it would start slow
then reach the top speed. then take time to decelerate. its a pretty pivotal
part of my game. any help would be appreciated. thx in advance
[F8] Mole Smash Style Flash Game Source...?
I am working on a site for a charity and they want to try and get a flash game on there with very little budget
They like the old mole smash style game (like this: http://www.flashmx-templates.com/fla...tun_attack.htm) but want it customised a bit so I need the source.
Has anyone come accross a free/much cheaper source code for this type of game around?
Thanks alot
Raise The Flag Game In Track And Field Style
Hi guys
I need your help. I am trying to make this game where you bash two keys (right and left arrow) to raise a flag, like Track and Field. If you press the keys correctly the flag goes up if you press them incorrectly it goes down. But now I´m stuck, I can´t manage to get the flag moving. Could someone please help?
Creating A Bust-A-Move Style Bubble Game?
Hello guys! I`m interested in making a series of English Educational games in Flash for Japanese kids. (I`ve only made a small shooter and puzzle game before when I was using Flash 5 a long time ago... Now I want to get seriously into Flash Game Programming).
I have an entire suite of games in mind starting with a Bust-A-Move (Bubble Bobble) style game. The dynamics of this game evolve matching bubbles of the same color in 3`s which causes the bubbles to disappear (along with any other connecting bubbles of the same color) as they make their way from the top of the screen.
Attacking Bubbles are catapulted one of at a time from the bottom of the screen where player can aim, and cause them to bounce off walls in order to match them with bubbles falling from above. English words are encased in between the falling bubbles. Once freed, they fall to the line and become part of the player`s arsenal of "Puzzle Words" The player must use these words to form a correct sentence so that they can move on to the next puzzle.
At first glance, this game looks relatively simple to make, but unlike a normal shooting game, I don`t know how to make the Attacking Bubbles (ones in the catapult) selection become random. (For example, first catapult bubble is red, then next one is green, next one yellow etc...)
Does anyone know of any good examples for this style of game on the web that I can use for studying the action script involved? I`m using Gary Rozenzwieg`s Flash game programming book but this one is a little out of rang I think!
Any ideas? Thanx!
Whack-A-mole Style Game Actionscript Problems...
2nd problem is the Actionscript code. All of the script for my game is on a "Actions" movie clip on my main (root) timeline. Everytime I try to use it, nothing happens to my rat movie clip at all and I keep getting an error. Here is the code....
<cont...>
|