Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of github.com:bmac/pocket-universe

  • Loading branch information...
commit 69d4871f5312fd4812831808def2b30b456b10ac 2 parents f1632f1 + 1b41faf
Brendan McLoughlin authored April 21, 2012
4  Pocket Universe.as3proj
@@ -6,8 +6,8 @@
6 6
     <movie input="" />
7 7
     <movie path="bin\PocketUniverse.swf" />
8 8
     <movie fps="30" />
9  
-    <movie width="960" />
10  
-    <movie height="540" />
  9
+    <movie width="800" />
  10
+    <movie height="600" />
11 11
     <movie version="10" />
12 12
     <movie minorVersion="1" />
13 13
     <movie platform="Flash Player" />
2  src/DevState.as
@@ -17,7 +17,7 @@ package
17 17
 		{
18 18
 			// create all the planets for the level
19 19
 			planets = new FlxGroup();
20  
-			planets.add(new Planet(10, 20, 1, 16));
  20
+			planets.add(new Planet(10, 20, 1));
21 21
 			
22 22
 			// create all the obstacles for the level
23 23
 			obstacles = new FlxGroup();
59  src/Level.as
... ...
@@ -0,0 +1,59 @@
  1
+package  
  2
+{
  3
+	/**
  4
+	 * ...
  5
+	 * @author Vinny
  6
+	 */
  7
+	import org.flixel.*;
  8
+
  9
+	public class Level extends FlxState
  10
+	{
  11
+		private var camera:Camera;
  12
+		private var planets:FlxGroup = new FlxGroup();
  13
+		private var player:Player;
  14
+		private var obstacles:FlxGroup;
  15
+		private var music:MusicController;
  16
+
  17
+		//camera options
  18
+		private var cameraOrigin:FlxPoint = new FlxPoint(0, 0);
  19
+		private var width:int = 960;
  20
+		private var height:int = 540;
  21
+		private var zoom:int = 1;
  22
+		
  23
+
  24
+		public function CreatePlanets(planets:FlxGroup) : void 
  25
+		{
  26
+			throw Error("Please Override CreatePlanets Method");
  27
+		}
  28
+		
  29
+		override public function create():void
  30
+		{	
  31
+			this.CreatePlanets(planets);
  32
+			
  33
+			// create the player
  34
+			player = new Player(planets.members[0], planets);
  35
+			
  36
+			// create camera
  37
+			FlxG.camera.target = player;
  38
+			
  39
+			// start the music
  40
+			music = new MusicController();
  41
+			
  42
+			// add all to the world
  43
+			add(planets);
  44
+			//add(obstacles);
  45
+			add(player);
  46
+		}
  47
+		
  48
+		override public function update():void
  49
+		{
  50
+			super.update();
  51
+			if (player.getSuccess() == true)
  52
+			{
  53
+				//TODO: Determine what to do about win condition...
  54
+				FlxG.switchState(new MenuState());
  55
+			}
  56
+		}
  57
+	}
  58
+
  59
+}
13  src/LightbulbPlanet.as
... ...
@@ -1,12 +1,14 @@
1 1
 package  
2 2
 {
  3
+	import org.flixel.FlxPoint;
  4
+	
3 5
 	/**
4 6
 	 * ...
5 7
 	 * @author 
6 8
 	 */
7 9
 	public class LightbulbPlanet extends Planet
8 10
 	{
9  
-		public const LIGHTBULB_MASS:int = 1;
  11
+		public const LIGHTBULB_MASS:int = 5;
10 12
 		
11 13
 		private var planet_background:PlanetBackground;
12 14
 		
@@ -14,14 +16,17 @@ package
14 16
 		[Embed(source="../assets/planets/Lightblulb-surfaceanimation.png")] private var lightbulb_planet:Class;		
15 17
 		[Embed(source="../assets/planets/lightblulbbackground.png")] private var lightbulb_background:Class;
16 18
 		
17  
-		public function LightbulbPlanet(x:int, y:int, checkpoint:int) 
  19
+		public function LightbulbPlanet(x:int, y:int, scale:Number=1 ,checkpoint:int=0) 
18 20
 		{
19  
-			super(x, y, checkpoint, 332);
  21
+			super(x, y, checkpoint);
20 22
 			this.loadGraphic(lightbulb_planet, true, false, 332, 330);
21 23
 			this.addAnimation("Flash", [0, 1, 2, 3, 2, 1], 1, true);
22 24
 			planet_background = new PlanetBackground(this.x, this.y, lightbulb_background);
23 25
 			this.planetMass = LIGHTBULB_MASS;
24  
-			this.checkpoint = 0;			
  26
+			this.setSize (528 * scale);
  27
+			this.scale = new FlxPoint(scale, scale);
  28
+			planet_background.scale = new FlxPoint(scale, scale);
  29
+			this.checkpoint = checkpoint;			
25 30
 		}
26 31
 
27 32
 		
3  src/MenuState.as
... ...
@@ -1,5 +1,6 @@
1 1
 package
2 2
 {
  3
+	import levels.Level01;
3 4
 	import org.flixel.*;
4 5
 
5 6
 	public class MenuState extends FlxState
@@ -24,7 +25,7 @@ package
24 25
 		private function startGame():void
25 26
 		{
26 27
 			FlxG.mouse.hide();
27  
-			FlxG.switchState(new PlayState);
  28
+			FlxG.switchState(new Level01);
28 29
 		}
29 30
 		
30 31
 		private function devGame():void
4  src/Planet.as
@@ -20,12 +20,10 @@ package
20 20
 		 */
21 21
 		protected var checkpoint:int;
22 22
 		
23  
-		public function Planet(x:int, y:int, checkpoint:int, size:int) 
  23
+		public function Planet(x:int, y:int, checkpoint:int) 
24 24
 		{
25 25
 			this.checkpoint = checkpoint;
26 26
 			super(x, y);
27  
-			_size = size;
28  
-			this.loadGraphic(apple_sprite);
29 27
 		}
30 28
 		
31 29
 		//The Rectangular Size of this planet (ie the texture size)
128  src/PlayState.as
... ...
@@ -1,65 +1,65 @@
1  
-package
2  
-{
3  
-	import org.flixel.*;
4  
-
5  
-	public class PlayState extends FlxState
6  
-	{
7  
-		private var camera:Camera;
8  
-		private var planets:FlxGroup;
9  
-		private var player:Player;
10  
-		private var obstacles:FlxGroup;
11  
-		private var music:MusicController;
12  
-
13  
-		//camera options
14  
-		private var cameraOrigin:FlxPoint = new FlxPoint(0, 0);
15  
-		private var width:int = 960;
16  
-		private var height:int = 540;
17  
-		private var zoom:int = 1;
18  
-		
19  
-		
20  
-		public function PlayState()
21  
-		{
22  
-		}
23  
-
24  
-		override public function create():void
25  
-		{			
26  
-			// create all the planets for the level
27  
-			planets = new FlxGroup();
28  
-			planets.add(new SpongePlanet(250, 250, 1));
29  
-			//planets.add(new LightbulbPlanet(100, 70, 1));
30  
-			//planets.add(new LightbulbPlanet(800, 740, 0));
31  
-			//planets.add(new LightbulbPlanet(400, 490, 0));
32  
-			//planets.add(new SpongePlanet(50, 50, 1));
33  
-			//planets.add(new LightbulbPlanet(100, 70, 1));
34  
-			//planets.add(new LightbulbPlanet(800, 740, 0));
35  
-			//planets.add(new LightbulbPlanet(200, 150, 0));
36  
-			//planets.add(new SpongePlanet(50, 500, 1));
37  
-
38  
-			// create all the obstacles for the level
39  
-			//obstacles = new FlxGroup();
40  
-			
41  
-			// create the player
42  
-			player = new Player(planets.members[0], planets);
43  
-			
44  
-			// create camera
45  
-			FlxG.camera.target = player;
46  
-			
47  
-			// start the music
48  
-			music = new MusicController();
49  
-			
50  
-			// add all to the world
51  
-			add(planets);
52  
-			//add(obstacles);
53  
-			add(player);
54  
-		}
55  
-		
56  
-		override public function update():void
57  
-		{
58  
-			super.update();
59  
-			if (player.getSuccess() == true)
60  
-			{
61  
-				FlxG.switchState(new PlayState);
62  
-			}
63  
-		}
64  
-	}
  1
+package
  2
+{
  3
+	import org.flixel.*;
  4
+
  5
+	public class PlayState extends FlxState
  6
+	{
  7
+		private var camera:Camera;
  8
+		private var planets:FlxGroup;
  9
+		private var player:Player;
  10
+		private var obstacles:FlxGroup;
  11
+		private var music:MusicController;
  12
+
  13
+		//camera options
  14
+		private var cameraOrigin:FlxPoint = new FlxPoint(0, 0);
  15
+		private var width:int = 960;
  16
+		private var height:int = 540;
  17
+		private var zoom:int = 1;
  18
+		
  19
+		
  20
+		public function PlayState()
  21
+		{
  22
+		}
  23
+
  24
+		override public function create():void
  25
+		{			
  26
+			// create all the planets for the level
  27
+			planets = new FlxGroup();
  28
+			//planets.add(new SpongePlanet(250, 250, 1));
  29
+			planets.add(new LightbulbPlanet(100, 70, 1));
  30
+			//planets.add(new LightbulbPlanet(800, 740, 0));
  31
+			//planets.add(new LightbulbPlanet(400, 490, 0));
  32
+			//planets.add(new SpongePlanet(50, 50, 1));
  33
+			//planets.add(new LightbulbPlanet(100, 70, 1));
  34
+			//planets.add(new LightbulbPlanet(800, 740, 0));
  35
+			//planets.add(new LightbulbPlanet(200, 150, 0));
  36
+			//planets.add(new SpongePlanet(50, 500, 1));
  37
+
  38
+			// create all the obstacles for the level
  39
+			//obstacles = new FlxGroup();
  40
+			
  41
+			// create the player
  42
+			player = new Player(planets.members[0], planets);
  43
+			
  44
+			// create camera
  45
+			FlxG.camera.target = player;
  46
+			
  47
+			// start the music
  48
+			music = new MusicController();
  49
+			
  50
+			// add all to the world
  51
+			add(planets);
  52
+			//add(obstacles);
  53
+			add(player);
  54
+		}
  55
+		
  56
+		override public function update():void
  57
+		{
  58
+			super.update();
  59
+			if (player.getSuccess() == true)
  60
+			{
  61
+				FlxG.switchState(new PlayState);
  62
+			}
  63
+		}
  64
+	}
65 65
 }
13  src/Player.as
@@ -8,6 +8,7 @@ package
8 8
 	import org.flixel.FlxG;
9 9
 	import org.flixel.FlxU;
10 10
 	import org.flixel.FlxTimer;
  11
+	import flash.geom.Point;
11 12
 	
12 13
 	public class Player extends FlxSprite
13 14
 	{
@@ -20,7 +21,7 @@ package
20 21
 		
21 22
 		public const INPUT_VELOCITY:Number = 30;
22 23
 		public const G:Number = 90;
23  
-		public const ANTI_GRAVITY:Number = 4;
  24
+		public const ANTI_GRAVITY:Number = 250;
24 25
 		
25 26
 		//player win
26 27
 		private var levelSuccess:Boolean = false;
@@ -90,8 +91,14 @@ package
90 91
 			if (FlxG.keys.justPressed("SPACE") && (_currentPlanet != null)) {
91 92
 				var tempPlanet:Planet = _currentPlanet;
92 93
 				_currentPlanet = null;
93  
-				velocity.x = this.x - tempPlanet.getCenter().x * ANTI_GRAVITY;
94  
-				velocity.y = this.y - tempPlanet.getCenter().y * ANTI_GRAVITY;
  94
+				
  95
+				var tempPoint:Point = new Point
  96
+					(this.x - tempPlanet.getCenter().x, this.y - tempPlanet.getCenter().y);
  97
+				tempPoint.normalize(1);
  98
+				velocity.x = tempPoint.x * ANTI_GRAVITY;
  99
+				velocity.y = tempPoint.y * ANTI_GRAVITY;
  100
+				
  101
+				
95 102
 			}
96 103
 			
97 104
 			// player walks around the current planet using left and right arrow keys
12  src/SpongePlanet.as
... ...
@@ -1,5 +1,6 @@
1 1
 package  
2 2
 {
  3
+	import org.flixel.FlxPoint;
3 4
 	/**
4 5
 	 * ...
5 6
 	 * @author Chris
@@ -12,11 +13,14 @@ package
12 13
 		
13 14
 		[Embed(source = "../assets/planets/sponge.png")] private var sponge_planet:Class;		
14 15
 		
15  
-		public function SpongePlanet(x:int, y:int, checkpoint:int) 
16  
-		{
17  
-			super(x, y, checkpoint, 100);
  16
+		public function SpongePlanet(x:int, y:int, scale:Number=1 ,checkpoint:int=0) 
  17
+		{			
  18
+			super(x, y, checkpoint);
  19
+			
18 20
 			this.loadGraphic(sponge_planet);
19  
-			this.planetMass = SPONGE_MASS;		
  21
+			this.planetMass = SPONGE_MASS;
  22
+			this.setSize (528 * scale);
  23
+			this.scale = new FlxPoint(scale,scale);
20 24
 		}
21 25
 		
22 26
 		override public function playerCollision(player:Player):void
27  src/levels/Level01.as
... ...
@@ -0,0 +1,27 @@
  1
+package levels 
  2
+{
  3
+	import org.flixel.FlxGroup;
  4
+	/**
  5
+	 * ...
  6
+	 * @author Vinny
  7
+	 */
  8
+	public class Level01 extends Level
  9
+	{
  10
+		override public function CreatePlanets(planets:FlxGroup):void 
  11
+		{
  12
+			// create all the planets for the level
  13
+			planets.add(new SpongePlanet(350, 350, 0.5 ,1 ));
  14
+			planets.add(new LightbulbPlanet(20, 20, 0.5));
  15
+			/*planets.add(new LightbulbPlanet(800, 740, 0));
  16
+			planets.add(new LightbulbPlanet(400, 490, 0));
  17
+			planets.add(new SpongePlanet(50, 50, 1));
  18
+			planets.add(new LightbulbPlanet(100, 70, 1));
  19
+			planets.add(new LightbulbPlanet(800, 740, 0));
  20
+			planets.add(new LightbulbPlanet(200, 150, 0));
  21
+			planets.add(new SpongePlanet(50, 500, 1));
  22
+			/**/
  23
+		}
  24
+		
  25
+	}
  26
+
  27
+}

0 notes on commit 69d4871

Please sign in to comment.
Something went wrong with that request. Please try again.