Flash Punk Tutorial
Flash Punk Tutorial
Flash Punk Tutorial
Whats FlashPunk?
A free open-source 2D game engine for flash developers
FlashPunk Website
http://flashpunk.net
Setting Up (Step 1)
Step 1: Install FlashDevelop (a Flash IDE)
http://flashdevelop.org/
CLICK!
Setting Up (Step 2)
Step 2: Install Adobe Flex SDK
http://opensource.adobe.com/wiki/display/flexsd k/Download+Flex+4
CLICK!
Lets create another folder C:\Flash\Projects\ where we will make our examples in
10
Setting Up (Step 3)
Step 3: Install Debug Player
http://www.adobe.com/support/flashplayer/dow nloads.html
CLICK!
11
Setting Up (Step 4)
Step 4: Run and configure FlashDevelop
12
Configuring FlashDevelop
CLICK!
13
14
15
16
17
Editing Main.as
package { import flash.display.Sprite; public class Main extends Sprite { public function Main():void { trace("Hello IST446!"); } } }
18
20
Copying FlashPunk
Whenever you create a new project,
Copy the whole net folder into your project folder (under src in which Main.as is located)
21
22
26
27
Enabling Console
Console gives information on your entities public function Main():void { super(320, 240); FP.screen.scale = 2; FP.console.enable(); }
28
Console Window
29
30
Creating a World
Type in a class name (e.g. GameWorld) and choose net.flashpunk.World as a base class
31
32
A World Example
package { import net.flashpunk.World; public class GameWorld extends World { public function GameWorld() { trace("IST446 GameWorld constructed"); } override public function begin():void { super.begin(); } } }
33
34
35
38
Entities
Joe is a Player entity. And lets assume that football balls are his enemies (Enemy entities).
Player Entity
http://www.jfasites.com/Anderson/Anderson _Images/Joe_Paterno_Caricature.jpg
Enemy Entity
http://cdn.bleacherreport.net /images/team_logos/50x50/fa ntasy_football.png
39
Collision Detection
If Joe moves over a ball, he will get upset
40
Icon Files
Create a folder named graphics under the project location Put those two icon files in it
41
Player Entity
package { (import statements omitted) public class Player extends Entity { [Embed(source="../graphics/Joe_Paterno_Caricature.jpg")] private const PLAYER_GRAPHIC:Class; public var image:Image; public function Player() { image = new Image(PLAYER_GRAPHIC); image.scale = 0.5; graphic = image; setHitbox(50, 45, 0, 0); type = "player"; } (to be continued)
42
43
super.update();
}
44
Enemy
package { import net.flashpunk.Entity; import net.flashpunk.graphics.Image; import net.flashpunk.FP; public class Enemy extends Entity { [Embed(source = "../graphics/fantasy_football.png")] public const ENEMY_GRAPHIC:Class; public function Enemy() { graphic = new Image(ENEMY_GRAPHIC); x = FP.rand(FP.screen.width); y = FP.rand(FP.screen.height); type = "enemy"; setHitbox(50, 50, 0, 0); } } }
46
Joe!!
48
CLICK!
49
Joes HitBox
50
HitBoxes
52
53
54
Video Tutorials
55
Any Questions?
On Wednesday, well play with GameMaker Lite
http://www.yoyogames.com/gamemaker/
56