Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import net.flashpunk.Entity;
- import net.flashpunk.graphics.Image;
- import net.flashpunk.utils.Input;
- import net.flashpunk.utils.Key;
- import net.flashpunk.FP
- public class Pelaaja extends Entity
- {
- [Embed(source ='/../lib/Art/alusp.png')] private const PELAAJA:Class
- public var speed:int;
- public var spralus:Image = new Image(PELAAJA);
- public var health:Number;
- public var moving:Boolean;
- public var level:Number = 0;
- public var inputX:int = 0;
- public var inputY:int = 0;
- public var timer:Number = 0;
- public var time:Boolean;
- public function Pelaaja(x:int, y:int, time:Boolean)
- {
- super(x, y);
- graphic = spralus;
- Input.define("Right", Key.RIGHT);
- Input.define("Left", Key.LEFT);
- Input.define("Up", Key.UP);
- Input.define("Down", Key.DOWN);
- Input.define("Shoot", Key.X);
- Input.define("Timestop", Key.Z);
- Input.define("Quit", Key.ESCAPE);
- setHitbox(3, 4, -1, -2);
- centerOrigin();
- speed = 40;
- }
- override public function update(): void
- {
- inputX = 0;
- inputY = 0;
- if (Input.check("Right"))
- {
- inputX += 1;
- moving = true;
- }
- if (Input.check("Left"))
- {
- inputX -= 1;
- moving = true;
- }
- if (Input.check("Up"))
- {
- inputY -= 1;
- moving = true;
- }
- if (Input.check("Down"))
- {
- inputY += 1;
- moving = true;
- }
- if (Input.check("Shoot") == true && level == 0 && timer == 0)
- {
- world.add(new Laser1(x + 3, y, level, time));
- timer = 10;
- trace("niin");
- }
- if (Input.check("Shoot") == true && level == 1 && timer == 0)
- {
- world.add(new Laser1(x + 3, y, level, time));
- world.add(new Laser1(x, y + 2, level, time));
- world.add(new Laser1(x + 6, y + 2, level, time));
- timer = 10;
- trace("niin");
- }
- if (Input.check("Timestop"))
- {
- Kentta.time = true;
- }
- else
- {
- Kentta.time = false;
- }
- x += inputX * speed * FP.elapsed;
- y += inputY * speed * FP.elapsed;
- if (inputX == 0 && inputY == 0)
- {
- moving = false;
- }
- if (timer > 0)
- {
- timer -= 1;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment