Followers

Showing posts with label Game. Show all posts
Showing posts with label Game. Show all posts

Wednesday, April 8, 2015

Flash: Enemy Chase Code

import flash.events.Event;

stage.addEventListener(Event.ENTER_FRAME, gameLoop);

function gameLoop(evt:Event)
{
 if(enemy.x < player.x)
{
     enemy.x +=1;
}
if(enemy.x > player.x)
{
     enemy.x -=1;
}
if(enemy.y < player.y)
{
     enemy.y +=1;
}
if(enemy.y > player.y)
{
     enemy.y -=1;
}
}

Monday, March 30, 2015

Flash Mobile: Enemy Scroll and Collect Collectable Code

Below is Actionscript 3 code that once is input into your Actions Frame in Flash will allow your player character to move with the mouse, collect an object and the enemy will scroll from right to left.

(Originally published 2/11/15)


import flash.events.Event;
stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addChild(player);

var score = 0;
var health = 0;

player.x = stage.mouseX;
player.y = stage.mouseY;

function gameLoop(evt:Event)
{
player.x = stage.mouseX;
player.y = stage.mouseY;

collectable.x = collectable.x - 3;
enemy.x = enemy.x - 3;

        if(player.hitTestObject(enemy) && enemy.visible == true)
        {
     health = health - 5;
              enemy.visible = false;
        }

if(player.hitTestObject(collectable) && collectable.visible == true)
        {
     score = score +1;
              collectable.visible = false;
        }

        scoreDisplay.text = "Score:" + score;
        healthDisplay.text = "Health:" + health;

}

Thursday, May 15, 2014

Flash: Multiple Enemies

Here is the code for multiple enemies in your action game.

 //multiple enemies follow you

for(var i in enemies)
{
 if(enemies[i]._x < player._x) {
enemies[i]._x +=1;
}
if(enemies[i]._x > player._x) {
enemies[i]._x -=1;
}
if(enemies[i]._y < player._y) {
enemies[i]._y +=1;
}
if(enemies[i]._y > player._y) {
enemies[i]._y -=1;
}

}

// if the multiple enemies hits you
for(var i in enemies)
{
if(player.hitTest(enemies[i]) && enemies[i]._visible == true)
{
score = score - 1;
scoreDisplay.text = score;
player._x = 450;
player._y = 250;
enemies[i]._x = 0 - enemies._x;
enemies[i]._y = 0 - enemies._y;
}
}

Friday, August 30, 2013

Spot the Designer Flash Game

http://www.albinoblacksheep.com/games/designer

This FLASH game is kind of addictive.

Constructive criticism is an evaluation of performance, good and bad, with an eye to improvement rather than simple critique. It is designed to be helpful to the person being evaluated.

After playing the game a bit, write in your blogs about WHY you think their game is good or bad, and HOW you would improve it or change it to make it better. Help them, don't just compliment them.



Tuesday, October 30, 2012