Permalink
Browse files

William's changes

  • Loading branch information...
1 parent 9fa2fe3 commit f2af4af37ec892c79530abfb8b28289fa369833c @Draknek committed Feb 6, 2011
Showing with 311 additions and 11 deletions.
  1. +39 −0 Aimer.as
  2. +53 −0 BeamSpam.as
  3. +64 −0 CrossShooter.as
  4. +17 −2 Enemy.as
  5. +28 −2 Level.as
  6. +19 −7 Player.as
  7. +45 −0 Rotating.as
  8. +46 −0 Toolbox.as
View
@@ -0,0 +1,39 @@
+package
+{
+ import net.flashpunk.graphics.Image;
+ /**
+ * ...
+ * @author William David Hunt
+ */
+ public class Aimer extends Enemy
+ {
+ [Embed(source = 'assets/enemy_32_3.png')]
+ private const SPRITE:Class;
+
+ public function Aimer(_x:Number = 0, _y:Number = 0, _vx:Number = 0, _vy:Number = 0)
+ {
+ super(_x, _y, _vx, _vy);
+ image = new Image(SPRITE);
+ image.centerOO();
+ graphic = image;
+ }
+
+ override public function update():void
+ {
+ x += vx;
+ y += vy;
+
+ var p1:Player = Level(world).p1;
+ var p2:Player = Level(world).p2;
+
+ if (time % 150 == 0) {
+ shootAt(p1.x, p1.y);
+ shootAt(p2.x, p2.y);
+ }
+
+ time += 1;
+ }
+
+ }
+
+}
View
@@ -0,0 +1,53 @@
+package
+{
+ import net.flashpunk.graphics.Image;
+ /**
+ * ...
+ * @author William David Hunt
+ */
+ public class BeamSpam extends Enemy
+ {
+
+ [Embed(source = '../assets/enemy_32_1.png')]
+ private const SPRITE:Class;
+
+ private var angle:Number = 0;
+ private var targetX:Number;
+ private var targetY:Number;
+
+ public function BeamSpam(_x:Number = 0, _y:Number = 0, _vx:Number = 0, _vy:Number = 0)
+ {
+ super(_x, _y, _vx, _vy);
+ image = new Image(SPRITE);
+ image.centerOO();
+ graphic = image;
+ }
+
+ override public function update():void
+ {
+ if (time % 150 == 120) {
+ if (Toolbox.randBool()) {
+ targetX = Level(world).p1.x;
+ targetY = Level(world).p1.y;
+ } else {
+ targetX = Level(world).p2.x;
+ targetY = Level(world).p2.y;
+ }
+ } else if (time % 150 > 120) {
+ shootAt(targetX, targetY);
+ } else {
+ x += vx;
+ y += vy;
+ }
+
+ if (x < 0 || x > 640 || y < 0 || y > 480) {
+ world.remove(this);
+ }
+
+
+ time += 1;
+ }
+
+ }
+
+}
View
@@ -0,0 +1,64 @@
+package
+{
+ import net.flashpunk.graphics.Image;
+ /**
+ * ...
+ * @author William David Hunt
+ */
+ public class CrossShooter extends Enemy
+ {
+
+ [Embed(source = '../assets/enemy_32_2.png')]
+ private const SPRITE:Class;
+
+ private var angle:Number = 0;
+
+ private var dvx:Number;
+ private var dvy:Number;
+
+ public function CrossShooter(_x:Number = 0, _y:Number = 0, _vx:Number = 0, _vy:Number = 0)
+ {
+ super(_x, _y, _vx, _vy);
+ image = new Image(SPRITE);
+ image.centerOO();
+ graphic = image;
+
+ dvx = _vx;
+ dvy = _vy;
+ }
+
+ override public function update():void
+ {
+ x += vx;
+ y += vy;
+
+ angle += 1;
+ angle = angle % 360;
+
+ var pos:Array = Toolbox.movePoint(0, 0, angle, 1);
+ vx = pos[0] + dvx;
+ vy = pos[1] + dvy;
+
+ if (time % 60 == 0 && time % 120 != 0 ) {
+ shootAt(x + 100, y + 100);
+ shootAt(x - 100, y - 100);
+ shootAt(x - 100, y + 100);
+ shootAt(x + 100, y - 100);
+ } else if ( time % 120 == 0) {
+ shootAt(x + 100, y);
+ shootAt(x - 100, y);
+ shootAt(x, y + 100);
+ shootAt(x, y - 100);
+ }
+
+ if (x < 0 || x > 640 || y < 0 || y > 480) {
+ world.remove(this);
+ }
+
+
+ time += 1;
+ }
+
+ }
+
+}
View
@@ -7,17 +7,32 @@ package
public class Enemy extends Entity
{
+ [Embed(source='../assets/enemy_25_1.png')]
+ private const SPRITE:Class;
+
public var vx: Number = 0;
public var vy: Number = 0;
public var time:uint = 0;
+ protected var image:Image;
+
+ protected var p1:Player;
+
+ protected var p2:Player;
+
public function Enemy (_x:Number = 0, _y:Number = 0, _vx:Number = 0, _vy:Number = 0)
{
x = _x;
y = _y;
vx = _vx;
vy = _vy;
+
+ image = new Image(SPRITE);
+ image.centerOO();
+
+ graphic = image;
+
}
public override function update (): void
@@ -46,10 +61,10 @@ package
world.add(new Bullet(x, y, dx, dy));
}
- public override function render (): void
+/* public override function render (): void
{
Draw.circlePlus(x, y, 10, 0xFF0000);
- }
+ }*/
}
}
View
@@ -10,18 +10,44 @@ package
public var p1:Player;
public var p2:Player;
public var link:Link;
+ public var time:int = 0;
public function Level ()
{
add(p1 = new Player(100, 100, 0, 0, true));
add(p2 = new Player(540,380,0,0, false));
add(link = new Link(p1, p2));
-
- add(new Enemy(430, 160));
}
public override function update (): void
{
+ time++;
+ time = time % 2300;
+
+ switch(time) {
+ case 30:
+ add(new BeamSpam(320, 0,0,1));
+ break;
+ case 600:
+ add(new BeamSpam(100, 0,0,1));
+ add(new BeamSpam(620, 0,0,1));
+ break;
+ case 1200:
+ add(new BeamSpam(0, 100, 1, 0));
+ add(new BeamSpam(640, 380, -1, 0));
+ break;
+ case 1500:
+ add(new CrossShooter(320, 480, 0, -1));
+ break;
+ case 2010:
+ add(new CrossShooter(10, 10, 1, 1));
+ break;
+ case 2200:
+ add(new CrossShooter(630, 470, -1, -1));
+ break;
+ }
+
+
super.update();
}
View
@@ -7,8 +7,11 @@ package
public class Player extends Entity
{
- [Embed(source = '../assets/ship.png')]
- private const IMAGE:Class;
+ [Embed(source='../assets/p1.png')]
+ private const P1_IMAGE:Class;
+
+ [Embed(source='../assets/p2.png')]
+ private const P2_IMAGE:Class;
public var vx: Number = 0;
public var vy: Number = 0;
@@ -19,6 +22,8 @@ package
private var leftKey:int;
private var rightKey:int;
+ private var image:Image;
+
private const SPEED:Number = 3;
public function Player (_x:Number = 0, _y:Number = 0, _vx:Number = 0, _vy:Number = 0, _arrowKeys:Boolean = true )
@@ -44,7 +49,14 @@ package
rightKey = Key.D;
}
- addGraphic(new Image(IMAGE));
+ if (_arrowKeys) {
+ image = new Image(P1_IMAGE);
+ } else {
+ image = new Image(P2_IMAGE);
+ }
+
+ image.centerOO();
+ graphic = image;
}
public override function update (): void
@@ -69,10 +81,10 @@ package
y += vy;
}
- public override function render (): void
- {
- Draw.circlePlus(x, y, 20, 0x0000FF);
- }
+ //public override function render (): void
+ //{
+ //Draw.circlePlus(x, y, 20, 0x0000FF);
+ //}
}
}
View
@@ -0,0 +1,45 @@
+package
+{
+ import net.flashpunk.graphics.Image;
+ /**
+ * ...
+ * @author William David Hunt
+ */
+ public class Rotating extends Enemy
+ {
+
+ [Embed(source = '../assets/enemy_32_3.png')]
+ private const SPRITE:Class;
+
+ private var angle:Number = 0;
+
+ public function Rotating(_x:Number = 0, _y:Number = 0, _vx:Number = 0, _vy:Number = 0)
+ {
+ super(_x, _y, _vx, _vy);
+ image = new Image(SPRITE);
+ image.centerOO();
+ graphic = image;
+ }
+
+ override public function update():void
+ {
+ x += vx;
+ y += vy;
+
+ angle += 1;
+ angle = angle % 360;
+
+ var pos:Array = Toolbox.movePoint(0, 0, angle, 0.5);
+ vx = pos[0];
+ vy = pos[1];
+
+ if (time % 45 == 0 ) {
+ shootAt(x - pos[0], y - pos[1]);
+ }
+
+ time += 1;
+ }
+
+ }
+
+}
Oops, something went wrong.

0 comments on commit f2af4af

Please sign in to comment.