Followers

Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

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, February 5, 2015

Flash: Mobile Collectable Object Code

d. Scroll Your Collectable Object
  • Select your Actions layer and open the Actions window
  • In the gameLoop() function, add the following code to scroll your collectable to the left:
collectable.x = collectable.x -3;

Monday, January 19, 2015

khan academy.org

https://www.khanacademy.org

Learn how HTML and CSS work together to make websites.

Short videos and then an interactive lesson to assess learning where students can earn points, badges, and other virtual prizes to reward them and give a sense of accomplishment.

Code Academy.com

http://www.codecademy.com/

Learn to code interactively, for free.