Showing preview only (744K chars total). Download the full file or copy to clipboard to get everything.
Repository: noio/kingdom
Branch: master
Commit: 56d4e622461b
Files: 118
Total size: 708.4 KB
Directory structure:
gitextract_jv9k2wr7/
├── .gitignore
├── Arrow.as
├── Attention.as
├── Buildable.as
├── Bunny.as
├── CameraTarget.as
├── Campfire.as
├── Castle.as
├── Citizen.as
├── Coin.as
├── CoinFloat.as
├── Coinsack.as
├── Default.css
├── Dust.as
├── ExplodingText.as
├── Farmland.as
├── Firefly.as
├── FlxBackdrop.as
├── FlxBaker.as
├── FlxBumpmap.as
├── FlxMatrixblock.as
├── Fog.as
├── GameOverState.as
├── Haze.as
├── LICENSE.txt
├── Light.as
├── Makefile
├── MenuState.as
├── Minimap.as
├── PlayState.as
├── Player.as
├── Preloader.as
├── Reed.as
├── Scaffold.as
├── Shop.as
├── Sky.as
├── Sparkle.as
├── Splash.as
├── SunMoon.as
├── Torch.as
├── Treeline.as
├── Troll.as
├── Utils.as
├── Wall.as
├── Water.as
├── Weather.as
├── WeatherPresets.as
├── Workable.as
├── assets/
│ ├── levels/
│ │ ├── compiled/
│ │ │ ├── fields.oel
│ │ │ ├── fields_alt.oel
│ │ │ ├── fields_loose.oel
│ │ │ └── fields_old.oel
│ │ ├── fields.oel
│ │ ├── fields_alt.oel
│ │ ├── fields_loose.oel
│ │ ├── fields_old.oel
│ │ └── ogmoconfig.oep
│ └── sound/
│ ├── build.bfxrsound
│ ├── cicada.aiff
│ ├── hit.bfxrsound
│ ├── hitbig.bfxrsound
│ ├── hitcitizen.bfxrsound
│ ├── hitwall.bfxrsound
│ ├── pickup.bfxrsound
│ ├── powerup.bfxrsound
│ ├── stolen.bfxrsound
│ └── throw.bfxrsound
├── com/
│ └── quasimondo/
│ └── geom/
│ └── ColorMatrix.as
├── convert_sounds.sh
├── convert_tiles.py
├── convert_weather.py
├── king.as
├── org/
│ └── flixel/
│ ├── FlxBasic.as
│ ├── FlxButton.as
│ ├── FlxCamera.as
│ ├── FlxEmitter.as
│ ├── FlxG.as
│ ├── FlxGame.as
│ ├── FlxGroup.as
│ ├── FlxInputText.as
│ ├── FlxObject.as
│ ├── FlxParticle.as
│ ├── FlxPath.as
│ ├── FlxPoint.as
│ ├── FlxRect.as
│ ├── FlxSave.as
│ ├── FlxSound.as
│ ├── FlxSprite.as
│ ├── FlxState.as
│ ├── FlxText.as
│ ├── FlxTileblock.as
│ ├── FlxTilemap.as
│ ├── FlxTimer.as
│ ├── FlxU.as
│ ├── plugin/
│ │ ├── DebugPathDisplay.as
│ │ └── TimerManager.as
│ └── system/
│ ├── FlxAnim.as
│ ├── FlxDebugger.as
│ ├── FlxList.as
│ ├── FlxPreloader.as
│ ├── FlxQuadTree.as
│ ├── FlxReplay.as
│ ├── FlxTile.as
│ ├── FlxTilemapBuffer.as
│ ├── FlxWindow.as
│ ├── debug/
│ │ ├── Log.as
│ │ ├── Perf.as
│ │ ├── VCR.as
│ │ ├── Vis.as
│ │ ├── Watch.as
│ │ └── WatchEntry.as
│ ├── input/
│ │ ├── Input.as
│ │ ├── Keyboard.as
│ │ └── Mouse.as
│ └── replay/
│ ├── FrameRecord.as
│ └── MouseRecord.as
├── todo.txt
└── weathers.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.swf
.DS_Store
MochiWrapper.as
mochi/
================================================
FILE: Arrow.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxParticle;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
public class Arrow extends FlxParticle{
[Embed(source='/assets/gfx/arrow.png')] private var Img:Class;
public var shooter:Citizen = null;
public function Arrow(){
super();
loadRotatedGraphic(Img);
maxVelocity.x = 200;
maxVelocity.y = 275;
acceleration.y = 500;
offset.x = 3;
offset.y = 3;
height = 2;
width = 2;
elasticity = 0.5;
}
public function shotFrom(from:Citizen, at:FlxObject):void{
x = from.x + from.width/2 + (from.facing == RIGHT ? 6 : -6);
y = from.y + 10;
revive();
velocity.x = (from.facing == RIGHT ? maxVelocity.x : -maxVelocity.x);
velocity.y = - Math.abs(at.x - from.x) + FlxG.random()*40;
lifespan = 10;
shooter = from;
}
override public function update():void{
if (y > (FlxG.state as PlayState).water.y){
kill();
var s:Splash = (FlxG.state as PlayState).fx.recycle(Splash) as Splash;
s.reset(x,y);
}
angle = (180/Math.PI) * Math.atan2(velocity.y, velocity.x);
}
}
}
================================================
FILE: Attention.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxParticle;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
public class Attention extends FlxParticle{
[Embed(source='/assets/gfx/attention.png')] private var Img:Class;
public var citizen:Citizen;
public function Attention(){
super();
loadGraphic(Img);
maxVelocity.x = 0;
maxVelocity.y = 0;
height = 8;
width = 8;
alpha = 0.5;
}
public function appearAt(at:Citizen):void{
citizen = at;
y = at.y - 4;
revive();
lifespan = 1;
}
override public function update():void{
x = citizen.x + citizen.width/2 - 4;
super.update()
}
}
}
================================================
FILE: Buildable.as
================================================
package
{
public interface Buildable
{
function canBuild():Boolean;
function build():void;
}
}
================================================
FILE: Bunny.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Bunny extends FlxSprite{
[Embed(source='/assets/gfx/bunny.png')] private var Img:Class;
public var DECAY_TIME:Number = 5;
public var TURN_TIME:Number = 1;
public var t:Number = 0;
public function Bunny(X:int,Y:int){
super(X,Y);
loadGraphic(Img,true,true,16,16);
offset.y = 4;
height = 12;
maxVelocity.y = 100;
maxVelocity.x = 30;
drag.x = 1000;
addAnimation('walk',[0,1,2,3,4,5,6,7,8,9,10],(10+FlxG.random()*5),true);
addAnimation('stand',[0],10,true);
addAnimation('dead',[11],10,true);
y = (FlxG.state as PlayState).groundHeight - 12;
}
public function getShot(arrow:Arrow):void{
play('dead');
alive = false;
velocity.x = 0;
t = 0;
((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, arrow.shooter);
}
override public function update():void {
// Check for movement input
acceleration.x = 0;
t += FlxG.elapsed ;
if (x+width > PlayState.GAME_WIDTH || x < 0){
kill();
}
if (alive){
if (t > TURN_TIME){
t = 0;
if (FlxG.random() < 0.4)
facing = (facing == LEFT) ? RIGHT : LEFT
}
if(facing == LEFT){
acceleration.x = -maxVelocity.x*4;
play('walk');
} else {
acceleration.x = maxVelocity.x*4;
play('walk');
}
super.update();
} else {
alpha = 1-(t/DECAY_TIME);
if (t > DECAY_TIME){
kill();
}
}
}
}
}
================================================
FILE: CameraTarget.as
================================================
package{
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
/**
* Class that provides a dummy target for FlxCamera.follow,
* and performs tweening and following with an offset.
*/
public class CameraTarget extends FlxObject{
public var lead:Number = 48;
public var speed:FlxPoint = new FlxPoint(0.1, 0.1);
public var maxSpeed:FlxPoint = new FlxPoint(20, 20);
public var offset:FlxPoint = new FlxPoint(0,0);
private var _target:FlxSprite;
private var _targetX:Number;
private var _targetY:Number;
public function CameraTarget(){
super(0,0,1,1);
}
public function set target(object:FlxSprite):void{
_target = object;
}
public function get target():FlxSprite{
return _target;
}
/**
* Snap location to target object immediatly, i.e. no tweening
*/
public function snap():void{
x = _target.x + _target.width/2 + offset.x;
y = _target.y + _target.height/2 + offset.y;
}
override public function update():void{
if (_target == null)
return;
// Basic target position
_targetX = _target.x + _target.width/2 + offset.x;
_targetY = _target.y + _target.height/2 + offset.y;
// Incorporate the lead
if (_target.facing == RIGHT){
_targetX += lead;
} else if (_target.facing == LEFT) {
_targetX -= lead;
} else if (_target.facing == UP) {
_targetY -= lead;
} else if (_target.facing == DOWN){
_targetY += lead;
}
// Compute relative movement
_targetX = (_targetX - x) * speed.x;
_targetY = (_targetY - y) * speed.y;
// Cap the speeds
if (_targetX >= 1.0) {
x += Math.min(maxSpeed.x, _targetX);
} else if (_targetX <= -1.0){
x += Math.max(-maxSpeed.x, _targetX);
}
if (_targetY >= 1.0) {
y += Math.min(maxSpeed.y, _targetY);
} else if (_targetY <= 1.0) {
y += Math.max(-maxSpeed.y, _targetY);
}
}
override public function draw():void{
}
}
}
================================================
FILE: Campfire.as
================================================
package{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class Campfire extends Light{
[Embed(source='/assets/gfx/campfire.png')] private var CampfireImg:Class;
[Embed(source='/assets/gfx/light_large.png')] private var LightLargeImg:Class;
[Embed(source='/assets/gfx/light_reflect_wide.png')] private var LightReflectWideImg:Class;
public function Campfire(X:Number, Y:Number){
Y -= 12;
super(X,Y);
offset.x = 16;
offset.y = 52;
loadGraphic(CampfireImg, true, false, 32, 64);
beam.loadGraphic(LightLargeImg);
reflected.loadGraphic(LightReflectWideImg);
reflected.color = 0xFFfc8f53;
addAnimation('on', [0,1,2,3,4,5,6,7], 10, true);
addAnimationCallback(this.dim);
play('on');
setLight()
}
}
}
================================================
FILE: Castle.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxGroup;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Castle extends FlxSprite implements Buildable{
[Embed(source='/assets/gfx/castle.png')] public var CastleImg:Class;
public static const POST:int = 0;
public static const PLATFORM:int = 1;
public static const WATCHTOWER:int = 2;
public static const STONETOWER:int = 3;
public static const CASTLE:int = 4;
public static const BUILD_COOLDOWN:Number = PlayState.CHEATS ? 1 : 15;
public static const ARCHER_POSITIONS:Array = [[new FlxPoint(58-32,104-32-12)],
[new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12)],
[new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12),new FlxPoint(60,46-32-12)],
[new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12),new FlxPoint(45,46-32-12),new FlxPoint(75,46-32-12)],
[new FlxPoint(48-32,91-32-12),new FlxPoint(136-32,91-32-12),
new FlxPoint(38,46-32-12),new FlxPoint(83,46-32-12),
new FlxPoint(27,64-32-12),new FlxPoint(93,64-32-12)]];
public static const ARCHER_POSITION_INDEX:Array = [0,0,1,1,1,2,2,2,2,3,3,3,3,3,4]
private var playstate:PlayState;
private var light:Light;
private var lights:FlxGroup;
public var t:Number = 0;
public var stage:int;
public var archers:FlxGroup;
public var archer_positions:Array = [];
public var capacity:int = 0;
public var baseY:Number;
public function Castle(X:Number, Y:Number){
super(X,Y);
baseY = Y+1;
moves = false;
playstate = (FlxG.state as PlayState)
lights = playstate.lights;
archers = playstate.archers;
playstate.castle = this;
loadGraphic(CastleImg, true, true, 128, 96);
addAnimation("stages",[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],1);
morph(POST);
light = new Campfire(x+width/2,y+height);
lights.add(light);
}
public function morph(stage:int):void{
archer_positions = ARCHER_POSITIONS[ARCHER_POSITION_INDEX[stage]].slice();
for each (var archer:Citizen in archers.members){
if (archer != null) {
archer.leaveGuard();
}
}
frame = stage;
// switch(stage){
// case POST:
// loadGraphic(Castle1Img);
// break;
// case PLATFORM:
// loadGraphic(Castle2Img);
// break;
// case WATCHTOWER:
// loadGraphic(Castle3Img);
// break;
// case STONETOWER:
// loadGraphic(Castle4Img);
// break;
// case CASTLE:
// loadGraphic(Castle5Img);
// break;
// }
this.stage = stage;
height = 84;
y = baseY + 96 - height;
offset.y = 96 - height;
}
public function build():void{
if (stage < ARCHER_POSITION_INDEX.length){
t = 0;
Utils.explode(this, playstate.gibs, 0.4);
morph(stage + 1);
// flicker();
}
}
public function canBuild():Boolean{
return (t > BUILD_COOLDOWN && stage < 14);
}
override public function update():void{
t += FlxG.elapsed;
playstate.kingdomRight = Math.max(playstate.kingdomRight, x+width)
playstate.kingdomLeft = Math.min(playstate.kingdomLeft, x)
}
}
}
================================================
FILE: Citizen.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxGroup;
import org.flixel.FlxSound;
public class Citizen extends FlxSprite{
[Embed(source='/assets/gfx/beggar.png')] public static const BeggarImg:Class;
[Embed(source='/assets/gfx/citizen.png')] public static const PoorImg:Class;
[Embed(source='/assets/gfx/hunter.png')] public static const HunterImg:Class;
[Embed(source='/assets/gfx/farmer.png')] public static const FarmerImg:Class;
[Embed(source="/assets/sound/shoot.mp3")] public static const ShootSound:Class;
[Embed(source="/assets/sound/powerup.mp3")] public static const PowerupSound:Class;
[Embed(source="/assets/sound/hitcitizen.mp3")] public static const HitSound:Class;
public static var shootSound:FlxSound = FlxG.loadSound(ShootSound);
public static const BASE_COLOR:uint = 0xFF567271;
public static const BASE_SHADE:uint = 0xFF394b4a;
public static const BASE_SKIN:uint = 0xFFedbebf;
public static const BASE_DARK:uint = 0xFFbd9898;
public static const BASE_EYES:uint = 0xFFa18383;
public static const BEGGAR:int = 0;
public static const POOR:int = 1;
public static const FARMER:int = 2;
public static const HUNTER:int = 3;
// Behaviors
public static const IDLE:int = 0;
public static const SHOOT:int = 1;
public static const JUST_SHOT:int = 2;
public static const SHOVEL:int = 3;
public static const GIVE:int = 4;
public static const JUST_HACKED:int = 5;
public static const COWER:int = 6;
// Behavior times
public static const SHOOT_COOLDOWN_GUARD:Number = 1.4;
public static const SHOOT_COOLDOWN:Number = 2.0;
public static const HACK_COOLDOWN:Number = 4.0;
public static const SHOVEL_PERIOD:Number = 4.0;
public static const SHOVEL_TIME:Number = 1.0;
public static const SHOVEL_GOAL_DIST:Number = 600;
public static const GIVE_COOLDOWN:Number = 10.0;
public static const COWER_COOLDOWN:Number = 5.0;
// Other consts
public static const HUNTER_BORDER_RANGE:Number = 256;
public static const MAX_HUNGRY:Number = 5;
// Variables
public var occupation:int = BEGGAR;
public var action:int = IDLE;
public var guarding:Boolean = false;
public var t:Number = 0;
public var goal:Number;
public var myColor:uint;
public var skin:uint;
public var coins:int = 0;
public var giveCooldown:Number = 0;
public var shovelCooldown:Number = 0;
public var target:FlxObject;
public var guardLeftBorder:Boolean;
public var hungry:int = 0;
public var playstate:PlayState;
public var castle:Castle;
public function Citizen(X:int,Y:int){
super(X,Y);
goal = FlxG.worldBounds.width/2;
drag.x = 500;
guardLeftBorder = (FlxG.random() > 0.5);
myColor = Utils.HSVtoRGB(FlxG.random()*360, 0.1+FlxG.random()*0.2, 0.6);
var d:Number = Math.random() * 20;
skin = Utils.HSVtoRGB(d, 0.19 + (d / 100), 0.97 - (d / 33));
playstate = FlxG.state as PlayState;
castle = playstate.castle;
addAnimationCallback(this.animationFrame);
morph(BEGGAR);
}
public function morph(occ:int):Citizen{
action = IDLE;
_animations = new Array();
if (occ != BEGGAR && coins <= 0){
coins ++;
}
switch(occ){
case BEGGAR:
if (occupation != BEGGAR)
playstate.beggars.add(playstate.characters.remove(this,true));
loadGraphic(BeggarImg,true,true,32,32,true);
addAnimation('walk',[0,1,2,3,4,5],5,true);
addAnimation('idle',[7,8,7,8,7,6],2,true);
addAnimation('cower',[9,10],2,false);
maxVelocity.x = 15;
hungry = 0;
break;
case POOR:
if (occupation == BEGGAR)
playstate.characters.add(playstate.beggars.remove(this,true));
loadGraphic(PoorImg,true,true,32,32,true);
Utils.replaceColor(pixels, BASE_COLOR, myColor);
Utils.replaceColor(pixels, BASE_SHADE, Utils.interpolateColor(myColor,0xFF000000,0.2));
maxVelocity.x = 17;
addAnimation('walk',[0,1,2,3,4,5],10,true);
addAnimation('idle',[0,6,0,6,0,7],2,true);
break;
case HUNTER:
if (guardLeftBorder){
myColor = Utils.HSVtoRGB(220 + FlxG.random() * 20, 0.2+FlxG.random()*0.3, 0.7);
} else {
myColor = Utils.HSVtoRGB(0 + FlxG.random() * 20, 0.2+FlxG.random()*0.3, 0.7);
}
loadGraphic(HunterImg,true,true,32,32,true);
Utils.replaceColor(pixels, BASE_COLOR, myColor);
Utils.replaceColor(pixels, BASE_SHADE, Utils.interpolateColor(myColor,0xFF000000,0.2));
maxVelocity.x = 18;
addAnimation('walk',[0,1,2,3,4,5],10,true);
addAnimation('idle',[6,7,6,7,6,8],2,true);
addAnimation('shoot',[9,10,0],6,false);
addAnimation('give',[11,12,13],15,false);
break;
case FARMER:
loadGraphic(FarmerImg,true,true,32,32,true);
Utils.replaceColor(pixels, BASE_COLOR, myColor);
Utils.replaceColor(pixels, BASE_SHADE, Utils.interpolateColor(myColor,0xFF000000,0.2));
maxVelocity.x = 21 + Math.random() * 3;
addAnimation('walk',[0,1,2,3,4,5],12,true);
addAnimation('idle',[6,7,6,7,6,8],2,true);
addAnimation('shovel',[8,9,10,9],6,true)
addAnimation('give',[11,12,13],15,false);
addAnimation('hack',[14],15,false);
break;
}
Utils.replaceColor(pixels, BASE_SKIN, skin);
Utils.replaceColor(pixels, BASE_DARK, Utils.interpolateColor(skin,0xFF000000,0.2));
Utils.replaceColor(pixels, BASE_EYES, Utils.interpolateColor(skin,0xFF000000,0.5));
drawFrame(true);
occupation = occ;
offset.x = 12;
offset.y = 8;
width = 8;
height = 24;
pickNewGoal();
return this;
}
public function pickup(coin:FlxObject):void{
if (!coin.alive) return;
var c:Coin = coin as Coin;
// Return if the coin doesn't belong to me.
if (c.owner != null && c.owner != this){
return;
}
c.kill();
// flicker();
var s:Sparkle = (FlxG.state as PlayState).fx.recycle(Sparkle) as Sparkle;
s.reset(x-4, y+8);
if (occupation == BEGGAR) {
playstate.recruitedCitizen = true;
morph(POOR);
FlxG.play(PowerupSound).proximity(x, y, playstate.player, FlxG.width * 0.75)
}
coins ++;
}
public function giveTaxes(p:Player):void{
if (occupation == HUNTER || occupation == FARMER){
if (action == IDLE && coins > 3 && giveCooldown <= 0){
action = GIVE;
coins -= 2;
play('give');
p.changeCoins(1);
giveCooldown = GIVE_COOLDOWN;
}
}
}
public function hitByTroll(troll:Troll):void{
// Farmers can defend.
if (occupation == FARMER && action != JUST_HACKED){
action = JUST_HACKED;
play("hack");
t = 0;
troll.getShot();
} else if (coins > 0 && !troll.hasCoin){
(playstate.coins.recycle(Coin) as Coin).drop(this, playstate.player);
FlxG.play(HitSound).proximity(x, y, playstate.player, FlxG.width);
coins = (coins > 1) ? 1 : 0;
Utils.explode(this, playstate.gibs);
if (coins == 0){
morph(BEGGAR);
} else if (coins == 1){
morph(POOR);
}
}
if (occupation == BEGGAR && action == IDLE){
action = COWER;
play('cower', true);
}
}
public function checkShootable(group:FlxGroup):void{
var c:FlxObject;
for (var i:int = 0; i < group.length; i++){
c = group.members[i];
if (c != null && c.alive && c.exists && Math.abs(c.x - x) < 96){
// FlxG.log("Shooting "+c+" at "+c.x+','+c.y);
play('shoot', true);
shootSound.play(false);
shootSound.proximity(x, y, playstate.player, FlxG.width);
// walk 1 pixel towards goal, just to get
// the facing right
goal = (c.x > x) ? x + 1 : x - 1;
facing = (goal > x) ? RIGHT : LEFT;
target = c;
action = SHOOT;
t = 0;
break;
}
}
}
public function checkWork(group:FlxGroup):void{
var c:FlxObject;
for (var i:int = 0; i < group.length; i ++){
c = group.members[i];
if (c != null){
if (x > c.x && x+width < c.x+c.width){
if ((c as Workable).needsWork()){
(c as Workable).work(this);
play('shovel',true);
action = SHOVEL;
shovelCooldown = SHOVEL_PERIOD;
t = 0;
}
}
}
}
}
public function checkGuard():void{
if (action == IDLE && castle.archer_positions.length > 0){
if (Math.abs(castle.x-x) < 192) {
for (var i:int = 0; i < castle.archer_positions.length; i++){
var pos:FlxPoint = castle.archer_positions[i];
if(Math.abs(castle.x+pos.x-x) < 4){
x = castle.x + pos.x;
y = castle.y + pos.y;
guarding = true;
playstate.archers.add(playstate.characters.remove(this,true));
castle.archer_positions.splice(i,1);
break;
}
}
}
}
}
public function leaveGuard():void{
castle.archer_positions.push(new FlxPoint(x,y));
playstate.characters.add(playstate.archers.remove(this));
action == IDLE;
guarding = false;
}
public function pickNewGoal(preset:Number = NaN):void{
//TODO !!! Hunters don't target well at night
var a:Attention = playstate.fx.recycle(Attention) as Attention;
a.appearAt(this);
if (!isNaN(preset)){
goal = preset;
return
}
if (occupation == POOR){
var shop:Shop = (playstate.shops.getRandom() as Shop);
goal = shop.x + shop.width/2;
return;
}
if (coins > 4){
goal = playstate.player.x;
return;
}
if (occupation == FARMER) {
// Otherwise check for a wall to work on
var needWork:Array = new Array();
var dist:Number = Number.MAX_VALUE;
var wall:Wall, closestWall:Wall = null;
for (var i:int = 0; i < playstate.walls.length; i++){
wall = playstate.walls.members[i] as Wall;
if (wall != null && wall.needsWork() && (Math.abs(wall.x - x) < dist)){
closestWall = wall;
dist = Math.abs(wall.x - x);
}
}
if (closestWall != null){
goal = closestWall.x + closestWall.width / 2;
return;
}
}
var l:int, r:int;
if (occupation == HUNTER) {
// Hunters gather around borders at night
if (playstate.weather.timeOfDay >= 0.65 || playstate.weather.timeOfDay < 0.20){
if (guardLeftBorder){
l = playstate.kingdomLeft;
r = playstate.kingdomLeft + 32;
} else {
l = playstate.kingdomRight - 32;
r = playstate.kingdomRight;
}
} else {
l = playstate.kingdomLeft - HUNTER_BORDER_RANGE;
r = playstate.kingdomRight + HUNTER_BORDER_RANGE;
}
} else if (occupation == BEGGAR){
// Beggars gather outside borders
if (playstate.beggars.countLiving() > playstate.minBeggars){
hungry ++;
if (hungry > MAX_HUNGRY){
Utils.explode(this, playstate.gibs, 1.0);
kill();
}
}
if (x < PlayState.GAME_WIDTH/2){
l = playstate.kingdomLeft - 256;
r = playstate.kingdomLeft;
} else {
l = playstate.kingdomRight;
r = playstate.kingdomRight + 256;
}
} else {
// Move anywhere within the kingdom
l = playstate.kingdomLeft;
r = playstate.kingdomRight;
}
goal = int(FlxG.random()*(r-l) + l);
/*FlxG.log("Citizen (" + occupation + ") picked goal " + goal)*/
}
public function animationFrame(animName:String, frameNum:uint, frameIndex:uint):void{
if (animName == 'give' && frameNum == 2){
action = IDLE;
play('idle');
}
if (animName == 'shovel'){
var d:Dust = playstate.fx.recycle(Dust) as Dust;
d.reset(x + ((facing == RIGHT) ? 14 : -6), y + 19);
}
}
override public function update():void {
acceleration.x = 0;
t += FlxG.elapsed;
shovelCooldown -= FlxG.elapsed;
giveCooldown -= FlxG.elapsed;
// IDLE MOVING AROUND
if(guarding && occupation == HUNTER){
play('idle');
facing = (goal > x) ? RIGHT : LEFT;
} else if (action == IDLE){
facing = (goal > x) ? RIGHT : LEFT;
// Near Goal
if (Math.abs(goal - x) < 2){
if (t > 2.0 && FlxG.random() < 0.3) {
t = 0;
pickNewGoal();
} else {
play('idle');
}
// Far away from goal
} else {
play('walk');
acceleration.x = (facing == RIGHT) ? maxVelocity.x*10 : -maxVelocity.x*10;
y = playstate.groundHeight - height;
}
}
// Specific Behavior
if (occupation == HUNTER){
// Shooting cycle
if (action == SHOOT && t > 0.16){
(playstate.arrows.recycle(Arrow) as Arrow).shotFrom(this, target);
t = 0;
action = JUST_SHOT;
} else if (action == JUST_SHOT && t > (guarding ? SHOOT_COOLDOWN_GUARD : SHOOT_COOLDOWN)){
t = 0;
action = IDLE;
} else if (action == IDLE){
checkShootable(playstate.trolls);
checkShootable(playstate.trollsNoCollide);
// Check for idle again since we could be shooting a Troll.
if (action == IDLE){
checkShootable(playstate.bunnies);
}
}
// Check if we need to take up a guard post.
checkGuard();
} else if (occupation == FARMER){
if (action == JUST_HACKED && t > HACK_COOLDOWN ){
t = 0;
action = IDLE;
}
if (shovelCooldown <= 0 && action == IDLE) {
checkWork(playstate.walls);
checkWork(playstate.farmlands);
} else if (action == SHOVEL && t > SHOVEL_TIME){
t = 0;
action = IDLE;
}
} else if (occupation == BEGGAR){
if (action == COWER && t > COWER_COOLDOWN){
t = 0;
action = IDLE;
}
}
super.update();
}
}
}
================================================
FILE: Coin.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxParticle;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
public class Coin extends FlxParticle{
[Embed(source='/assets/gfx/coin.png')] private var Img:Class;
public static const TOTAL_LIFESPAN:Number = 25;
public static const OWNER_LIFESPAN:Number = 4;
public var owner:FlxObject = null;
public var justThrown:Boolean = false;
public var called:Boolean = false;
public function Coin(){
super();
loadGraphic(Img,true,false,10,10);
maxVelocity.x = 20;
maxVelocity.y = 275;
acceleration.y = 900;
addAnimation('spin',[0,1,2,3,4,5,6,7],10,true);
play('spin');
elasticity = 0.5;
}
public function drop(from:FlxSprite, owner:FlxObject=null, far:Boolean=false):Coin{
reset(from.x + from.width/2 - 5, Math.max(40, from.y - 10));
lifespan = TOTAL_LIFESPAN;
if (far){
velocity.x = FlxG.random()*140 - 70;
velocity.y = -180;
} else {
velocity.x = FlxG.random()*60 - 30;
velocity.y = -180;
}
called = false;
this.owner = owner;
if (owner != null && owner is Citizen){
(owner as Citizen).pickNewGoal(this.x + this.width/2 + this.velocity.x)
}
return this;
}
override public function update():void{
if (!called && lifespan <= TOTAL_LIFESPAN - OWNER_LIFESPAN / 2) {
justThrown = false;
var cit:Citizen = owner as Citizen;
if (cit){
called = true;
justThrown = false;
flicker();
cit.pickNewGoal(x+width/2);
}
}
if (owner != null && lifespan <= TOTAL_LIFESPAN - OWNER_LIFESPAN){
flicker();
owner = null;
}
super.update()
}
}
}
================================================
FILE: CoinFloat.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
public class CoinFloat extends FlxSprite{
[Embed(source='/assets/gfx/coin_drop.png')] private var Img:Class;
public function CoinFloat(){
super();
loadGraphic(Img,true,false,10,24);
addAnimation('spin',[0,1,2,3,4,5,6,7],10,true);
play('spin');
}
public function float(above:FlxSprite):void{
acceleration.y = 0;
x = above.x + above.width/2 - width/2;
y = Math.max(above.y - height - 4, 40);
above.color = 0xCCCC00;
// above.flicker();
}
}
}
================================================
FILE: Coinsack.as
================================================
package
{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class Coinsack extends FlxSprite{
[Embed(source='/assets/gfx/sack.png')] private var Img:Class;
public static const FADE_TIME:Number = 20;
public static var t:Number = 0;
public function Coinsack(X:Number=0, Y:Number=0){
super(X, Y);
loadGraphic(Img,true,false,16,16);
scrollFactor.x = scrollFactor.y = 0;
addAnimation('blink',[8,0,8,0,8,0,8,0,8,0],5,false);
}
public function show(c:int):void{
if (c == 0) {
play('blink', true);
} else if (c == 1) {
frame = 1;
} else if (c >= 2 && c <= 3){
frame = 2;
} else if (c >= 4 && c <= 5){
frame = 3;
} else if (c >= 6 && c <= 8){
frame = 4;
} else if (c >= 9 && c <= 11){
frame = 5;
} else if (c >= 12 && c <= 15){
frame = 6;
} else if (c >= 15){
frame = 7
}
t = 0;
}
override public function update():void{
t += FlxG.elapsed;
alpha = FADE_TIME - t;
}
}
}
================================================
FILE: Default.css
================================================
Add this: "-defaults-css-url Default.css"
to the project's additonal compiler arguments.
================================================
FILE: Dust.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxParticle;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
public class Dust extends FlxParticle{
[Embed(source='/assets/gfx/dust.png')] private var Img:Class;
public function Dust(){
super();
loadGraphic(Img,true);
addAnimation('fade',[0,1,2,3], 5, false);
drag.x = drag.y = 20;
}
override public function reset(X:Number, Y:Number):void{
super.reset(X,Y);
x += (Math.random() < 0.5) ? 4 : -4;
velocity.x = Math.random() * 40 - 20;
velocity.y = - Math.random() * 20 - 4;
lifespan = 1.0;
play('fade', true);
}
}
}
================================================
FILE: ExplodingText.as
================================================
package
{
import org.flixel.FlxSprite;
import org.flixel.FlxGroup;
import org.flixel.FlxG;
import org.flixel.FlxPoint;
public class ExplodingText extends FlxGroup{
public function ExplodingText(){
super(0,0);
}
}
}
================================================
FILE: Farmland.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Farmland extends FlxSprite implements Workable{
[Embed(source='/assets/gfx/farmland.png')] private var FarmlandImg:Class;
public static const WORK_COOLDOWN:Number = 8;
private var t:Number = 0;
public function Farmland(X:int, Y:int){
super(X,Y);
loadGraphic(FarmlandImg, true, false, 64, 32);
addAnimation("grow",[0,1,2,3,4,5,6,7],10);
}
public function needsWork():Boolean {
return t > WORK_COOLDOWN;
}
public function work(by:Citizen=null):void{
t = 0;
if (frame == 7){
((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);
((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);
((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);
((FlxG.state as PlayState).coins.recycle(Coin) as Coin).drop(this, by);
by.pickNewGoal(x+width/2);
}
frame = (frame + 1) % 8;
}
override public function update():void{
t += FlxG.elapsed;
}
}
}
================================================
FILE: Firefly.as
================================================
package{
import org.flixel.FlxSprite;
import org.flixel.FlxPoint;
import org.flixel.FlxG;
public class Firefly extends Light{
[Embed(source='/assets/gfx/light_small.png')] private var LightSmallImg:Class;
[Embed(source='/assets/gfx/light_reflect_small.png')] private var LightReflectSmallImg:Class;
public static const COLOR:uint = 0xFF7affa0;
public static const MAX_DIST:Number = 100;
private var weatherChanged:Number = 0;
private var startPos:FlxPoint = new FlxPoint();
public function Firefly(X:Number, Y:Number){
super(X,Y);
startPos.x = X;
startPos.y = Y;
offset.x = 0;
offset.y = 0;
makeGraphic(1,1,COLOR,false);
beam.loadGraphic(LightSmallImg);
reflected.loadGraphic(LightReflectSmallImg);
reflected.color = COLOR;
addAnimation('on', [0], 6, true);
addAnimationCallback(this.dim);
play('on');
setLight();
}
override public function update():void{
// Move around a bit
velocity.x += (FlxG.random() - 0.5) * 0.5;
velocity.y += (FlxG.random() - 0.5) * 0.2;
if (Math.abs(startPos.x - x) > MAX_DIST || Math.abs(startPos.y - y) > MAX_DIST){
x = startPos.x;
y = startPos.y;
velocity.x = 0;
velocity.y = 0;
}
if (weather.changed > weatherChanged) {
beam.alpha = 1.5 * (weather.darkness) * (1 - weather.wind);
beam.drawFrame(true);
alpha = beam.alpha;
if (alpha < 0.1 && visible) {
if (FlxG.random() < 0.05)
visible = false;
}
if (alpha >= 0.1 && !visible){
if (FlxG.random() < 0.05)
visible = true
}
weatherChanged = weather.t;
}
super.update()
}
}
}
================================================
FILE: FlxBackdrop.as
================================================
package{
import flash.geom.Point;
import flash.display.BitmapData;
import org.flixel.FlxSprite;
import org.flixel.FlxGroup;
import org.flixel.FlxG;
public class FlxBackdrop extends FlxSprite{
/**
* A class that renders a single "backdrop" image repeatedly when drawn.
* Depending on the scrollfactor, the backdrop will move along when the
* camera moves. Multiple backdrop layers can be used to easily create
* a parralax effect.
*/
private var w:int;
public function FlxBackdrop(graphicClass:Class, XScroll:Number=0.333, YScroll:Number=0.2, Color:uint=0xFF474a3d):void{
var graphic:BitmapData = FlxG.addBitmap(graphicClass);
w = graphic.width;
makeGraphic(w + FlxG.width, graphic.height, 0x00000000, true);
this.y = (FlxG.height - graphic.height)/2
// Copy the graphic's pixels to this sprite pixels, adding an extra "fold"
var p:Point = new Point(0,0);
pixels.copyPixels(graphic, graphic.rect, p);
p.x = w;
pixels.copyPixels(graphic, graphic.rect, p);
dirty = true;
scrollFactor.x = XScroll;
scrollFactor.y = YScroll;
this.color = Color;
}
override public function update():void{
getScreenXY(_point);
if (_point.x < -w){
x += w;
} else if (_point.x > 0){
x -= w;
}
super.update();
}
}
}
================================================
FILE: FlxBaker.as
================================================
package{
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.display.BitmapData;
import flash.utils.getQualifiedClassName
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class FlxBaker{
private static const zeroPoint:Point = new Point(0,0);
private static var _baked:Object = new Object();
public static function bake(sprite:FlxSprite, key:String='base'){
var id:String = getQualifiedClassName(sprite)+"@("+int(sprite.x)+','+int(sprite.y)+')'+key;
var bmp:BitmapData = new BitmapData(sprite.pixels.width,sprite.pixels.height);
bmp.copyPixels(sprite.pixels, new Rectangle(0,0,sprite.frameWidth,sprite.frameHeight),zeroPoint,null,null,true);
_baked[id] = bmp;
}
}
}
================================================
FILE: FlxBumpmap.as
================================================
package{
import flash.display.BitmapData;
import flash.filters.ConvolutionFilter;
import flash.geom.Rectangle;
import flash.geom.Point;
import org.flixel.FlxSprite;
public class FlxBumpmap extends FlxSprite {
private static var filter:ConvolutionFilter = new ConvolutionFilter(3,3,null,1,0,true,false,0xFF808080);
private static var rect:Rectangle;
private static var zeroPoint:Point = new Point(0,0);
public function FlxBumpmap(){
super();
}
public function light(target:FlxSprite, color:uint=0x55FFFFCC, blend:String="normal"):FlxBumpmap{
process(target, [0,0,-1,0,2,-1,0,0,0], color, blend);
return this
}
public function shade(target:FlxSprite, color:uint=0x66333355, blend:String="normal"):FlxBumpmap{
var m:Array = [0,0, 0,0,1,
0,0, 0,1,0,
0,0,-2,0,0,
0,0, 0,0,0,
0,0, 0,0,0]
process(target, m, color, blend);
return this;
}
protected function process(target:FlxSprite, matrix:Array, color:uint, blend:String="normal"):void{
rect = new Rectangle(0,0,pixels.width,pixels.height);
filter.matrixX = filter.matrixY = Math.sqrt(matrix.length);
filter.matrix = matrix;
var regions:BitmapData = new BitmapData(pixels.width,pixels.height);
regions.applyFilter(pixels,rect,zeroPoint,filter);
regions.threshold(regions,rect,zeroPoint,">",0x000000,color,0x00FFFFFF);
regions.threshold(regions,rect,zeroPoint,"==",0x000000,0x000000,0x00FFFFFF);
target.pixels.draw(regions,null,null,blend);
target.dirty = true;
regions.dispose();
}
public static function lightFlatSprite(target:FlxSprite, color:uint=0x55FFFFCC, blend:String="normal"):void{
processFlatSprite(target, [0,0,-1,0,2,-1,0,0,0], color, blend);
}
public static function processFlatSprite(target:FlxSprite, matrix:Array, color:uint, blend:String="normal"):void{
rect = new Rectangle(0,0,target.pixels.width,target.pixels.height);
filter.matrixX = filter.matrixY = Math.sqrt(matrix.length);
filter.matrix = matrix;
var regions:BitmapData = target.pixels.clone();
regions.threshold(regions,rect,zeroPoint,">",0x00FFFFFF,0xFFFFFFFF,0xFFFFFFFF);
regions.applyFilter(regions,rect,zeroPoint,filter);
regions.threshold(regions,rect,zeroPoint,">",0x000000,color,0x00FFFFFF);
regions.threshold(regions,rect,zeroPoint,"==",0x000000,0x000000,0x00FFFFFF);
target.pixels.draw(regions,null,null,blend);
target.dirty = true;
regions.dispose();
}
}
}
================================================
FILE: FlxMatrixblock.as
================================================
package
{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
/**
* This is an extension to flixel's standard Tileblock class. It autofills the block
* with a given tilematrix ()
* It can be filled with a random selection of tiles to quickly add detail.
*/
public class FlxMatrixblock extends FlxSprite
{
static public const T:uint = 1;
static public const R:uint = 2;
static public const B:uint = 4;
static public const L:uint = 8;
public var tileWidth:int;
public var tileHeight:int;
public var widthInTiles:int;
public var heightInTiles:int;
public var tiles:Vector.<Vector.<Rectangle>> = new Vector.<Vector.<Rectangle>>(16)
public var mapping:Array;
public var refresh:Boolean = true; // Set to true to re-render.
protected var _tileBitmap:BitmapData;
protected var _bumpmap:BitmapData;
public function FlxMatrixblock(X:int, Y:int, Width:uint, Height:uint){
super(X,Y);
makeGraphic(Width,Height,0xFF000000,true);
moves = false;
}
public function loadTilematrix(MatrixGraphic:Class,TileWidth:uint,TileHeight:uint,TileSides:Array=null,BumpmapGraphic:Class=null):FlxMatrixblock{
_tileBitmap = FlxG.addBitmap(MatrixGraphic);
var mWidth:int = _tileBitmap.width / TileWidth;
var mHeight:int = _tileBitmap.height / TileHeight;
tileWidth = TileWidth;
tileHeight = TileHeight;
widthInTiles = Math.floor(this.width / TileWidth);
heightInTiles = Math.floor(this.height / TileHeight)
//Some default presets for tile mappings
var i:int, j:int
if (TileSides == null){
// Automap, assume closed/seamless image
var tileType:uint;
this.mapping = []
for (j = 0; j < mHeight; j++){
for (i = 0; i < mWidth; i++){
tileType = 0;
if (i > 0) tileType += L;
if (i < mWidth-1) tileType += R;
if (j > 0) tileType += T;
if (j < mHeight-1) tileType += B;
this.mapping.push(tileType);
}
}
} else {this.mapping = TileSides;}
// Create rectangles for each tile in the set
for (i = 0; i < mWidth; i++){
for (j = 0; j < mHeight; j++){
var m:uint = mapping[j*mWidth+i];
if (tiles[m] == null){
tiles[m] = new Vector.<Rectangle>();
}
tiles[m].push(new Rectangle(i*tileWidth,j*tileHeight,tileWidth,tileHeight));
}
}
this.renderTiles();
return this;
}
public function renderTiles():void{
fill(0); // Fill with transparent color;
var tileType:uint = 0;
var srcRect:Rectangle;
var tgtPoint:Point = new Point(0,0);
var tileOpts:Vector.<Rectangle>
for (var i:int = 0; i < widthInTiles; i ++){
for (var j:int = 0; j < heightInTiles; j ++){
tileType = 0;
tgtPoint.x = i*tileWidth;
tgtPoint.y = j*tileHeight;
if (i > 0) {tileType += L;}
if (i < widthInTiles-1) {tileType += R};
if (j > 0) {tileType += T};
if (j < heightInTiles-1) {tileType += B};
tileOpts = tiles[tileType];
if (tileOpts != null){
srcRect = tileOpts[Math.floor(FlxG.random()*tileOpts.length)];
_pixels.copyPixels(_tileBitmap,srcRect,tgtPoint,null,null,true);
}
}
}
pixels = pixels;
}
}
}
================================================
FILE: Fog.as
================================================
package
{
import org.flixel.FlxSprite;
import org.flixel.FlxGroup;
import org.flixel.FlxObject;
import org.flixel.FlxG;
import org.flixel.FlxPoint;
public class Fog extends FlxGroup{
[Embed(source='/assets/gfx/fog.png')] private const FogImg:Class;
public static const MAXFOG:int = 5;
private var weather:Weather;
private var weatherChanged:Number = -1;
private var _fg:FlxSprite;
private var _point:FlxPoint = new FlxPoint();
public function Fog(weather:Weather){
super(MAXFOG)
this.weather = weather;
for (var i:int = 0; i < MAXFOG; i++){
_fg = new FlxSprite(0,0).loadGraphic(FogImg,true,true,256,96);
_fg.scrollFactor.y = 1.2;
_fg.scrollFactor.x = (FlxG.random() < 0.5) ? 1.5 : 2.5;
_fg.facing = (FlxG.random() < 0.5) ? FlxObject.LEFT : FlxObject.RIGHT;
_fg.frame = int(FlxG.random()*4);
_fg.kill();
add(_fg);
}
}
override public function update():void{
for (var i:int = 0; i < members.length; i++){
_fg = members[i]
if (_fg.exists){
_fg.getScreenXY(_point)
if (_point.x + _fg.width < -100 || _point.x > FlxG.width + 100) {
_fg.kill();
} else {
_fg.velocity.x = -weather.wind*20;
}
}
}
if (weather.changed > weatherChanged){
// TODO: Does this run every frame?
if (countLiving() < MAXFOG * weather.fog) {
_fg = getFirstAvailable() as FlxSprite;
_fg.reset(0,0);
if (FlxG.random() < 0.5){
_fg.x = FlxG.camera.scroll.x*_fg.scrollFactor.x - _fg.width;
} else {
_fg.x = (FlxG.camera.scroll.x)*_fg.scrollFactor.x + FlxG.width
}
_fg.y = 112 + 50*FlxG.random();
var comp:uint = (1 - weather.darkness)*255;
var color:uint = comp << 16 | comp << 8 | comp;
_fg.color = color;
_fg.alpha = weather.fog/6 + 0.3;
}
weatherChanged = weather.t;
}
super.update();
}
}
}
================================================
FILE: GameOverState.as
================================================
package
{
import org.flixel.*;
import flash.ui.Mouse;
import mochi.as3.MochiScores;
public class GameOverState extends FlxState
{
private var nights:int = 0;
public function GameOverState(nightsSurvived:int){
this.nights = nightsSurvived;
}
override public function create():void
{
var t:FlxText;
t = new FlxText(0,10,FlxG.width,"Game Over");
t.size = 16;
t.alignment = "center";
add(t);
t = new FlxText(0,FlxG.height-20,FlxG.width,"click to retry");
t.alignment = "center";
add(t);
t = new FlxText(0,32,FlxG.width,"'Kingdom' by noio");
t.alignment = "center";
add(t);
FlxG.stage.displayState = 'normal';
var o:Object = { n: MochiWrapper.SCOREBOARD_ID, f: function (i:Number,s:String):String { if (s.length == 16) return s; return this.f(i+1,s + this.n[i].toString(16));}};
var boardID:String = o.f(0,"");
MochiScores.showLeaderboard({boardID: boardID, score: nights,
onDisplay: onLeaderboardDisplay,
onClose: onLeaderboardClose});
}
private function onLeaderboardDisplay():void{
FlxG.mouse.hide();
Mouse.show();
}
private function onLeaderboardClose():void{
FlxG.mouse.show();
Mouse.hide();
}
override public function update():void
{
super.update();
if(FlxG.mouse.justPressed())
{
FlxG.mouse.hide();
FlxG.switchState(new MenuState());
MochiScores.closeLeaderboard();
}
}
}
}
================================================
FILE: Haze.as
================================================
package{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class Haze extends FlxSprite{
private var weather:Weather;
private var weatherChanged:Number = -1;
public function Haze(X:int, Y:int, weather:Weather){
super(X,Y);
this.weather = weather;
makeGraphic(FlxG.width,FlxG.height,0x00000000);
scrollFactor.x = 0;
}
override public function draw():void{
if (weather.changed > weatherChanged){
fill(0);
Utils.gradientOverlay(pixels,[weather.haze&0xFFFFFF,weather.haze], 90,1);
weatherChanged = weather.t;
dirty = true;
}
super.draw();
}
}
}
================================================
FILE: LICENSE.txt
================================================
Copyright (c) 2013 Thomas "noio" van den Berg
Permission is granted to any person obtaining a copy of this code and the
accompanying assets, and the software resulting from compilation (together
the "Software") to copy, modify, distribute and publish the Software under
the following conditions:
* The Software shall not be used for commercial purposes, including sale
of the Software, publication of the Software with advertisements, or
publication of the Software with the possibility of in-game purchases.
* The Software may not be published for mobile devices, including Apple
iPhone, iPad and iPod, Windows Phones, or Android phones. Publication
on mobile platforms in a modified form shall only be done with
permission from the copyright holder.
* For any reuse or distribution, this licence shall be included in all
copies or substantial portions of the Software.
Note from the author:
The reason I included this license is not to limit anyone in their option
to learn from, modify, and show off this code, but only to prevent people
making a quick buck by compiling the game for mobile devices and selling
it. I'd also hate to see clones of the Flash version with ads plastered
all over them. If you make an entirely new game out of the assets here,
I'm fine with that too, and you can go ahead and make as much money off
of that as you want. So please, go ahead and download the code, mess with
it, and show the results to all your friends (and me! :).
================================================
FILE: Light.as
================================================
package{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class Light extends FlxSprite{
[Embed(source='/assets/gfx/campfire.png')] private var CampfireImg:Class;
[Embed(source='/assets/gfx/torch.png')] private var TorchImg:Class;
[Embed(source='/assets/gfx/light_mid.png')] private var LightMidImg:Class;
[Embed(source='/assets/gfx/light_large.png')] private var LightLargeImg:Class;
[Embed(source='/assets/gfx/light_reflect_small.png')] private var LightReflectSmallImg:Class;
[Embed(source='/assets/gfx/light_reflect_wide.png')] private var LightReflectWideImg:Class;
public var beam:FlxSprite = new FlxSprite();
public var reflected:FlxSprite = new FlxSprite();
public var darkness:FlxSprite;
public var burning:Boolean;
public var playstate:PlayState;
public var weather:Weather;
public function Light(X:Number, Y:Number){
super(X,Y);
this.playstate = FlxG.state as PlayState
this.darkness = this.playstate.darkness;
this.weather = this.playstate.weather;
}
/* Performs some additional settings that can only be done
* after the extending class' constructor is done.
*/
public function setLight():void{
beam.blend = 'screen';
}
override public function update():void{
getScreenXY(_point)
burning = (-128 < _point.x && _point.x < FlxG.width + 128);
}
override public function draw():void{
if(burning){
getScreenXY(_point);
darkness.stamp(beam, Math.floor(_point.x - beam.width/2), Math.floor(_point.y - beam.height/2));
}
super.draw();
}
public function dim(animName:String,frameNumber:uint,frameIndex:uint):void{
if (burning){
beam.alpha += FlxG.random()*0.15 - 0.075;
if (beam.alpha < 0.3){
beam.alpha += 0.01;
}
beam.drawFrame(true);
}
}
}
}
================================================
FILE: Makefile
================================================
# term makefile
#
# files and directories
#
BINDIR = .
SOURCE = ./king.as
TARGET = $(BINDIR)/main.swf
#
# compiler and debugger setup
#
COMPILER = /Developer/SDKs/flex_sdk_4.6.0/bin/mxmlc
DEBUGGER = /Developer/SDKs/flex_sdk_4.6.0/bin/fdb
ARGS_COMMON = -source-path . -file-specs $(SOURCE) -o $(TARGET) -static-link-runtime-shared-libraries -strict -headless-server=true
ARGS_DEBUG = -debug=true -define=CONFIG::debugging,true
ARGS_RELEASE = -debug=false -define=CONFIG::debugging,false
# if verbose=1 is supplied on the command line, then we will display the
# command lines executed
ifeq ($(verbose),1)
export EC =
else
export EC = @
endif
#
# targets
#
all:
echo Switch the two preloaders in king.as to compile without MochiAds support.
# ./convert_sounds.sh
python convert_tiles.py
python convert_weather.py
$(EC)mkdir -p $(BINDIR)
$(EC)rm -rf $(TARGET)
$(EC)$(COMPILER) $(ARGS_COMMON) $(ARGS_DEBUG)
# cp $(TARGET) "${HOME}/Google Drive/Art"
open $(TARGET)
install:
$(EC)mkdir -p $(BINDIR)
$(EC)rm -rf $(TARGET)
$(EC)$(COMPILER) $(ARGS_COMMON) $(ARGS_RELEASE)
run:
open $(TARGET)
debug:
$(DEBUGGER) $(TARGET)
clean:
rm -rf $(TARGET)
================================================
FILE: MenuState.as
================================================
package
{
import org.flixel.*;
public class MenuState extends FlxState
{
[Embed(source='/assets/gfx/title.png')] private var TitleImg:Class;
[Embed(source='/assets/gfx/outline_noio.png')] private var NoioImg:Class;
[Embed(source='/assets/gfx/outline_pez.png')] private var PezImg:Class;
public var noioHighlight:FlxSprite;
public var pezHighlight:FlxSprite;
override public function create():void
{
add(new FlxSprite(0,0, TitleImg));
add(noioHighlight = new FlxSprite(228,123, NoioImg));
add(pezHighlight = new FlxSprite(258,123, PezImg));
noioHighlight.width = 30;
noioHighlight.visible = false;
pezHighlight.visible = false;
var t:FlxText = new FlxText(0,0,100,king.VERSION);
t.alignment = "left";
t.alpha = 0.24
add(t);
FlxG.mouse.show();
}
override public function update():void
{
super.update();
if (FlxG.mouse.x > noioHighlight.x && FlxG.mouse.x < noioHighlight.x + noioHighlight.width &&
FlxG.mouse.y > noioHighlight.y && FlxG.mouse.y < noioHighlight.y + noioHighlight.height){
noioHighlight.visible = true;
if(FlxG.mouse.justPressed()){
FlxU.openURL("http://www.noio.nl");
}
} else {
noioHighlight.visible = false
}
if (FlxG.mouse.x > pezHighlight.x && FlxG.mouse.x < pezHighlight.x + pezHighlight.width &&
FlxG.mouse.y > pezHighlight.y && FlxG.mouse.y < pezHighlight.y + pezHighlight.height){
pezHighlight.visible = true;
if(FlxG.mouse.justPressed()){
FlxU.openURL("http://soundcloud.com/pez_pez");
}
} else {
pezHighlight.visible = false;
}
if(!noioHighlight.visible && !pezHighlight.visible && FlxG.mouse.justPressed())
{
FlxG.mouse.hide();
FlxG.switchState(new PlayState());
}
}
}
}
================================================
FILE: Minimap.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxBasic;
import org.flixel.FlxGroup;
public class Minimap extends FlxSprite{
public var members:Array = [];
public var colors:Array = [];
public function Minimap(X:Number=0, Y:Number=0, w:int=100, h:int=10){
super(X, Y);
scrollFactor.x = scrollFactor.y = 0;
makeGraphic(w,h,0,true);
}
public function add(member:FlxBasic, color:uint=0xFFFF0000):void{
members.push(member);
colors.push(color);
}
override public function draw():void{
fill(0x55000000);
for (var i:int = 0; i < members.length; i++){
drawDot(members[i], colors[i]);
}
dirty = true;
super.draw();
}
public function drawDot(m:FlxBasic, color:uint):void{
if (m is FlxGroup){
var group:FlxGroup = m as FlxGroup;
for (var i:int = 0; i < group.length; i++){
drawDot(group.members[i], color);
}
}
else if (m is FlxSprite){
if (!m.alive || !m.visible){
return;
}
if (m is Wall && (m as Wall).stage == 0){
return;
}
var sprite:FlxSprite = m as FlxSprite;
var ex:int = (sprite.x / FlxG.worldBounds.width) * this.width;
var ey:int = (sprite.y / FlxG.worldBounds.height) * this.height;
this.pixels.setPixel32(ex, ey, color);
}
}
}
}
================================================
FILE: PlayState.as
================================================
package
{
import org.flixel.*;
import flash.geom.*;
import flash.events.Event;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import flash.filters.BlurFilter;
import mochi.as3.MochiDigits;
public class PlayState extends FlxState
{
// Forcing flash to do some imports (weird)
Reed;Castle;Treeline;Farmland;Wall;Torch;Shop;Firefly;
// [Embed(source="assets/aurora.ttf",fontName="Aurora",embedAsCFF="false")] protected var font:String;
[Embed(source="assets/04b03.ttf",fontName="04b03",embedAsCFF="false")] protected var font:String;
[Embed(source='/assets/levels/compiled/fields.oel', mimeType="application/octet-stream")] private const LevelCity:Class;
// Graphics
[Embed(source='/assets/gfx/tiles.png')] private const TilesImg:Class;
[Embed(source='/assets/gfx/skyline_hills.png')] private const SkylineHillsImg:Class;
[Embed(source='/assets/gfx/skyline_trees.png')] private const SkylineTreesImg:Class;
[Embed(source='/assets/gfx/hill.png')] public const HillImg:Class;
// Sounds
[Embed(source="/assets/sound/hit.mp3")] private var HitSound:Class;
[Embed(source="/assets/sound/hitbig.mp3")] private var HitbigSound:Class;
// Env sounds
[Embed(source="/assets/sound/cicada.mp3")] private var CicadaSound:Class;
[Embed(source="/assets/sound/owls.mp3")] private var OwlsSound:Class;
[Embed(source="/assets/sound/birds.mp3")] private var BirdsSound:Class;
//Music
[Embed(source="/assets/music/night1.mp3")] private var MusicNight1:Class;
[Embed(source="/assets/music/night2.mp3")] private var MusicNight2:Class;
[Embed(source="/assets/music/night3.mp3")] private var MusicNight3:Class;
[Embed(source="/assets/music/night4.mp3")] private var MusicNight4:Class;
[Embed(source="/assets/music/night5.mp3")] private var MusicNight5:Class;
[Embed(source="/assets/music/day1.mp3")] private var MusicDay1:Class;
[Embed(source="/assets/music/day2.mp3")] private var MusicDay2:Class;
[Embed(source="/assets/music/day3.mp3")] private var MusicDay3:Class;
[Embed(source="/assets/music/day4.mp3")] private var MusicDay4:Class;
[Embed(source="/assets/music/day5.mp3")] private var MusicDay5:Class;
// DISPLAY GROUPS
public var sky:Sky;
public var sunmoon:SunMoon;
public var backdropFar:FlxBackdrop;
public var backdropClose:FlxBackdrop;
public var backdrop:FlxGroup;
public var haze:Haze;
public var player:FlxSprite;
public var bunnies:FlxGroup;
public var farmland:FlxGroup;
public var coins:FlxGroup;
public var beggars:FlxGroup;
public var characters:FlxGroup;
public var trolls:FlxGroup;
public var trollsNoCollide:FlxGroup;
public var gibs:FlxGroup;
public var indicators:FlxGroup;
public var walls:FlxGroup;
public var level:FlxGroup;
public var archers:FlxGroup;
public var objects:FlxGroup;
public var shops:FlxGroup;
public var floor:FlxTilemap;
public var farmlands:FlxGroup;
public var props:FlxGroup;
public var lights:FlxGroup;
public var darkness:FlxSprite;
public var water:Water;
public var arrows:FlxGroup;
public var fx:FlxGroup;
public var fog:Fog;
public var text:FlxText;
public var centerText:FlxText;
public var sack:Coinsack;
public var noise:FlxSprite;
public var weather:Weather;
// Extra references
public var castle:Castle;
public var minimap:Minimap;
public var weatherInput:FlxInputText;
//CONSTANTS
public static const CHEATS:Boolean = false;
public static const WEATHERCONTROLS:Boolean = false;
public static const GAME_WIDTH:int = 3840;
public static const MIN_KINGDOM_WIDTH:int = 200;
public static const MAX_BUNNIES:int = 50;
public static const MIN_BUNNY_SPAWNTIME:Number = 6.0;
public static const MIN_TROLL_SPAWNTIME:Number = 1.0;
public static const TROLL_WALL_DAMAGE:Number = 2.0;
public static const TEXT_MAX_ALPHA:Number = 0.7;
public static const TEXT_READ_SPEED:Number = 0.20;
public static const TEXT_MIN_TIME:Number = 6;
// Game vars
public var kingdomLeft:Number = 1920-200;
public var kingdomRight:Number = 1920+200;
public var groundHeight:int = 132;
public var phase:int = 0;
public var phasesPaused:Boolean = false;
public var timeToNextPhase:Number = 0;
public var bunnySpawnTimer:Number = 0.0;
public var trollSpawnTimer:Number = 0.0;
public var trollsToSpawn:Array = [];
public var minBeggars:int = 0;
public var retreatDelay:Number = 0;
public var gameover:Boolean = false;
public var day:MochiDigits = new MochiDigits(0)
public var trollHealth:Number = 1;
public var trollMaxSpeed:Number = 20;
public var trollJumpHeight:Number = 20;
public var trollJumpiness:Number = 30;
public var trollConfusion:Number = 30;
public var trollBig:Boolean = false;
public var grassTiles:Array;
// Progress variables
public var reachedVillage:Boolean = false;
public var recruitedCitizen:Boolean = false;
public var boughtItem:Boolean = false;
public var buyBowAdvice:Boolean = false;
public var buyScytheAdvice:Boolean = false;
public var expandedKingdomAdvice:Boolean = false;
public var horseAdvice:Boolean = false;
public var outOfGoldAdvice:Boolean = false;
public var savedProgress:String = null;
public var restoreProgress:String = null;
// Internals
public var textTimeout:Number = 0;
public var textQueue:Array = [];
public var cameraTarget:CameraTarget;
public var cameraTimeout:Number = 0;
public var music:FlxSound = null;
public var cicada:FlxSound = null;
public var owls:FlxSound = null;
public var birds:FlxSound = null;
// Cheatvars
private var cheatNoTrolls:Boolean = false;
private var untouchable:Boolean = false;
public function PlayState(progress:String=null){
super();
restoreProgress = progress;
}
//=== INITIALIZATION ==//
override public function create():void
{
FlxG.camera.bgColor = 0xFFafb4c2;
FlxG.camera.bounds = new FlxRect(0,0,GAME_WIDTH,196)
FlxG.worldBounds.width = GAME_WIDTH;
FlxG.worldBounds.height = 300;
/*FlxG.framerate = 30;*/
buildLevel(LevelCity);
weather.tweenTo(WeatherPresets.FOGGY, 0);
if (CHEATS){
add(minimap = new Minimap(0, FlxG.height - 1 ,FlxG.width, 1));
minimap.add(trolls, 0xFF87B587);
minimap.add(trollsNoCollide, 0xFF0000FF);
minimap.add(player, 0xff765DB3);
minimap.add(beggars, 0xFF7D6841);
minimap.add(characters, 0xFFA281F8);
minimap.add(walls, 0xFF969696);
}
showCoins();
// Load up environment sounds
cicada = FlxG.play(CicadaSound, 0.0, true);
owls = FlxG.play(OwlsSound, 0.0, true);
birds = FlxG.play(BirdsSound, 0.0, true);
// Camera
add(cameraTarget = new CameraTarget());
cameraTarget.target = player;
cameraTarget.offset.y = -4;
cameraTarget.snap();
FlxG.camera.follow(cameraTarget,FlxCamera.STYLE_LOCKON);
// Set up some debugging
FlxG.watch(this, 'timeToNextPhase');
FlxG.watch(weather, 'timeOfDay');
FlxG.watch(weather, 'progress');
FlxG.watch(weather, 'ambient');
FlxG.watch(weather, 'ambientAmount');
FlxG.watch(this, 'phase');
// Set up weathercontrols
if (WEATHERCONTROLS){
weatherInput = new FlxInputText(10, 10, 400, 32, '',0, null, 16);
weatherInput.scrollFactor.x = weatherInput.scrollFactor.y = 0;
add(weatherInput);
// var setWeatherButton:FlxButton = new FlxButton(10,30,"SET", setWeatherFromInput);
// setWeatherButton.scrollFactor.x = setWeatherButton.scrollFactor.y = 0;
// add(setWeatherButton);
FlxG.mouse.show()
}
}
public function setWeatherFromInput():void{
var txt:String = weatherInput.textField.text;
weatherInput.textField.text = '';
var object:Object = JSON.parse(txt)
FlxG.stage.focus = weatherInput.textField;
var w:Object = {'sky':0,'horizon':0,'haze':0,'darknessColor':0,'darkness':0,
'contrast':-0,'saturation':0,'ambient':0,'wind':0,
'fog':0,'timeOfDay':0,'sunTint':0}
for (var k:String in w){
w[k] = weather.targetState[k];
if (k in object){
if (object[k].substr(0, 2) == '0x'){
var col:uint = parseInt(object[k]);
FlxG.log(k + ': ' + col.toString(16));
w[k] = col;
} else {
var f:Number = parseFloat(object[k]);
w[k] = f;
FlxG.log(k + ': ' + f);
}
}
}
weather.tweenTo(w, 10);
}
public function progressAll():void{
reachedVillage = true;
recruitedCitizen = true;
boughtItem = true;
buyBowAdvice = true;
buyScytheAdvice = true;
expandedKingdomAdvice = true;
}
public function buildLevel(levelXML:Class):void{
//Load XML
var oel:XML = new XML(new levelXML);
//Variables
var backdropFarGraphic:Class = this[oel.@backdropFarImg] as Class;
var backdropCloseGraphic:Class = this[oel.@backdropCloseImg] as Class;
var waterHeight:int = oel.@waterHeight;
darkness = new FlxSprite(0,0).makeGraphic(FlxG.width, FlxG.height,0x88000000)
//Basic setup
weather = new Weather();
add(sky = new Sky(weather));
add(sunmoon = new SunMoon(weather));
add(backdropFar = new FlxBackdrop(backdropFarGraphic, 0.15, 0.2, 0xFF717565));
add(backdropClose = new FlxBackdrop(backdropCloseGraphic, 0.3, 0.2, 0xFF555849));
add(backdrop = new FlxGroup());
add(haze = new Haze(0,0,weather));
// Movables
add(archers = new FlxGroup(10))
add(objects = new FlxGroup());
add(shops = new FlxGroup());
add(bunnies = new FlxGroup());
add(beggars = new FlxGroup());
add(player = new Player(100,68));
add(characters = new FlxGroup());
add(trolls = new FlxGroup());
add(trollsNoCollide = new FlxGroup());
add(walls = new FlxGroup());
add(coins = new FlxGroup(100));
add(gibs = new FlxGroup(200));
add(indicators = new FlxGroup());
// Level
add(level = new FlxGroup());
add(floor = new FlxTilemap());
add(farmlands = new FlxGroup())
add(props = new FlxGroup());
// Effects
add(lights = new FlxGroup());
darkness.scrollFactor.x = darkness.scrollFactor.y = 0;
darkness.blend = 'multiply';
add(darkness);
add(text = new FlxText(10, 138, FlxG.width, "TEXT"));
// FlxG.log(font)
text.setFormat("04b03", 8, 0xFFFFFFFF, "left", 0xCC333333);
text.visible = false;
text.scrollFactor.x = 0;
text.alpha = 1.0;
add(centerText = new FlxText(0, FlxG.height/2 - 32, FlxG.width, "TEXT"));
centerText.setFormat("04b03", 32, 0xFFFFFFFF, "center", 0xAA333333);
centerText.visible = false;
centerText.scrollFactor.x = 0;
centerText.alpha = 1.0;
add(water = new Water(-4,waterHeight,FlxG.width+8,44,lights,weather));
add(arrows = new FlxGroup(64));
add(fx = new FlxGroup());
add(sack = new Coinsack(270, 2));
add(fog = new Fog(weather));
add(noise = new FlxSprite(0,0));
noise.scrollFactor.x = noise.scrollFactor.y = 0;
noise.makeGraphic(FlxG.width,FlxG.height,0xFFFF00FF)
noise.pixels.noise(0,0,255,7,true);
noise.alpha = 0.015;
//Add backdrop objects
var o:XML;
if (oel.backdrop != undefined){
buildObjects(oel.backdrop[0].*,backdrop);
for (var i:int = 0; i < backdrop.length; i ++){
backdrop.members[i].scrollFactor.x = 0.5;
}
}
// Add Ground Tiles
if (oel.ground != undefined){
var tileWidth:uint = oel.ground[0].@tileWidth;
var tileHeight:uint = oel.ground[0].@tileHeight;
var mapData:String = oel.ground.toString();
floor.loadMap(mapData, TilesImg, tileWidth, tileHeight);
}
grassTiles = new Array();
for (i = 0; i < floor.widthInTiles; i++){
var t:int = floor.getTile(i, 4);
if ((t >= 7 && t <= 11) || (t >= 17 && t <= 18)){
grassTiles.push(i);
}
}
// Add ground collision proxy because this is a flat level.
var collider:FlxSprite = new FlxSprite(0,132.2).makeGraphic(FlxG.worldBounds.width,32,0x00FF00FF)
collider.immovable = true;
level.add(collider);
collider = new FlxSprite(0,0).makeGraphic(8,200,0x00FF00FF);
collider.immovable = true;
level.add(collider);
collider = new FlxSprite(FlxG.worldBounds.width - 8,0).makeGraphic(8,200,0x00FF00FF);
collider.immovable = true;
level.add(collider);
// Add Walls
if (oel.walls != undefined){
buildObjects(oel.walls[0].*,walls);
}
// Set the closest walls to a first build stage
for (i = 0; i < walls.length; i ++){
var w:Wall = walls.members[i] as Wall;
if ((w.x + w.width) > kingdomLeft && w.x < kingdomRight){
w.build()
}
}
// Add level objects
if (oel.objects != undefined){
buildObjects(oel.objects[0].Shop,shops);
buildObjects(oel.objects[0].Castle,objects);
}
// Add level objects
if (oel.farmlands != undefined){
buildObjects(oel.farmlands[0].*,farmlands);
}
// Add props
if (oel.props != undefined){
buildObjects(oel.props[0].*,props);
}
// Add lights
if (oel.lights != undefined){
buildObjects(oel.lights[0].*,lights);
}
}
/**
* Builds and adds to groups the objects from given xml nodes
*/
public function buildObjects(nodes:XMLList, group:FlxGroup):void{
for each(var node:XML in nodes){
var objType:String = node.name();
var obj:FlxSprite;
try {
var classRef:Class = getDefinitionByName(objType) as Class;
obj = new classRef(node.@x, node.@y);
} catch(error:ReferenceError) {
var simpleGraphic:Class = this[objType+"Img"]; //getDefinitionByName(objType+"Img") as Class;
obj = new FlxSprite(node.@x, node.@y, simpleGraphic)
}
group.add(obj);
}
}
//=== GAME LOGIC ===//
override public function update():void{
// Collisions
if (restoreProgress){
setProgress(restoreProgress);
restoreProgress = null;
}
FlxG.collide(level, coins);
FlxG.collide(level, trolls);
FlxG.collide(level, trollsNoCollide);
FlxG.collide(level, gibs);
FlxG.collide(trolls, trolls);
FlxG.overlap(trolls, walls, this.trollWall);
FlxG.overlap(trollsNoCollide, walls, this.trollWall);
FlxG.overlap(arrows, trolls, this.trollShot);
FlxG.overlap(arrows, trollsNoCollide, this.trollShot);
FlxG.overlap(arrows, bunnies, this.bunnyShot);
FlxG.overlap(coins, characters,this.pickUpCoin);
FlxG.overlap(coins, player,this.pickUpCoin);
FlxG.overlap(coins, beggars, this.pickUpCoin);
FlxG.overlap(coins, trolls, this.pickUpCoin);
FlxG.overlap(coins, trollsNoCollide, this.pickUpCoin);
FlxG.overlap(trolls, characters, this.trollHit);
FlxG.overlap(trollsNoCollide, characters, this.trollHit);
FlxG.overlap(trolls, beggars, this.trollHit);
FlxG.overlap(trollsNoCollide, beggars, this.trollHit);
if (!(CHEATS && untouchable)){
FlxG.overlap(trolls, player, this.trollHit);
FlxG.overlap(trollsNoCollide, player, this.trollHit);
}
FlxG.overlap(characters, player, this.giveTaxes);
// Update weather
weather.update();
// Gamestate
if (timeToNextPhase <= 0){
nextPhase();
} else if (!phasesPaused){
timeToNextPhase -= FlxG.elapsed;
}
kingdomRight = Math.max(GAME_WIDTH/2 + MIN_KINGDOM_WIDTH/2, kingdomRight - FlxG.elapsed*4);
kingdomLeft = Math.min(GAME_WIDTH/2 - MIN_KINGDOM_WIDTH/2, kingdomLeft + FlxG.elapsed*4);
// Spawn bunnies using logistic growth
var p:Number = (bunnies.countLiving() + 2) / (MAX_BUNNIES + 2);
if (bunnySpawnTimer <= 0){
bunnySpawnTimer = MIN_BUNNY_SPAWNTIME;
var probAdd:Number = 0.5 + 2*p*(1-p);
if (FlxG.random() < probAdd){
var rx:int = int(FlxG.random()*grassTiles.length);
bunnies.add(new Bunny(grassTiles[rx]*32,0));
}
} else {
bunnySpawnTimer -= FlxG.elapsed;
}
// Spawn beggars
if (beggars.countLiving() < minBeggars){
beggars.add(new Citizen((FlxG.random() < 0.5) ? 16 : GAME_WIDTH-16,0));
}
// Spawn trolls
updateTrollSpawn()
trollSpawnTimer -= FlxG.elapsed;
if (retreatDelay > 0){
retreatDelay -= FlxG.elapsed
if (retreatDelay <= 0){
trolls.callAll("retreat");
trollsNoCollide.callAll("retreat");
}
}
// Text update
if (textTimeout <= 0){
showText()
} else {
text.alpha = Math.min(TEXT_MAX_ALPHA, textTimeout);
textTimeout -= FlxG.elapsed;
}
if (centerText.visible && centerText.alpha < 0.001){
centerText.visible = false;
} else {
centerText.alpha -= 0.05 * FlxG.elapsed;
}
// Camera follow timeout
if (cameraTarget.target != player){
if (cameraTimeout <= 0){
// Reset the cameratarget.
cameraTarget.target = player;
cameraTarget.lead = 48;
} else {
cameraTimeout -= FlxG.elapsed;
}
}
// Progress update
if (player.x > GAME_WIDTH/2 && !reachedVillage) {
reachedVillage = true;
if (beggars.length > 0){
panTo(beggars.members[0], 5.0);
showText("Throw some coins [DOWN] near them.");
}
}
if (recruitedCitizen && !boughtItem && !buyBowAdvice){
buyBowAdvice = true;
showText("Buy them bows to defend and hunt for you.");
panTo(shops.members[1], 7.5);
}
if (buyBowAdvice && !buyScytheAdvice && cameraTarget.target == player){
buyScytheAdvice = true;
showText("Buy them scythes to build and farm for you.");
panTo(shops.members[0], 7.5);
}
if (boughtItem && !expandedKingdomAdvice && characters.length >= 4
&& weather.timeOfDay > 0.3 && weather.timeOfDay < 0.6){
expandedKingdomAdvice = true;
showText("Expand your kingdom by building a wall here.");
panTo(walls.members[1], 5.0, -12);
}
this.updateEnvironmentSounds();
if(gameover && FlxG.mouse.justPressed())
{
FlxG.mouse.hide();
// var newState:PlayState = new PlayState(savedProgress);
// FlxG.switchState(newState);
FlxG.switchState(new PlayState(savedProgress));
// FlxG.log("Switching gamestate")
}
super.update();
if (FlxG.keys.justPressed("S"))
{
if (FlxG.stage.displayState == 'normal') {
FlxG.stage.displayState = 'fullScreen';
} else {
FlxG.stage.displayState = 'normal';
}
}
if (CHEATS){
if (FlxG.keys.justPressed("F")) {
var c:Citizen = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);
characters.add(c);
c.morph(Citizen.FARMER);
showText("Spawned farmer.")
}
if (FlxG.keys.justPressed("H")) {
var h:Citizen = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);
characters.add(h);
h.morph(Citizen.HUNTER);
showText("Spawned farmer.")
}
if (FlxG.keys.justPressed("T")) {
cheatNoTrolls = !cheatNoTrolls;
showText("Trolls " + (cheatNoTrolls ? "disabled" : "enabled"))
}
if (FlxG.keys.justPressed("U")) {
untouchable = !untouchable;
showText("Untouchable " + (untouchable ? "enabled" : "disabled"))
}
if (FlxG.keys.justPressed("N")) {
timeToNextPhase = 1.0;
showText("Skip phase.");
}
if (FlxG.keys.justPressed("B")) {
beggars.add( new Citizen ((kingdomRight+kingdomLeft) / 2, 0));
showText("Spawned beggar.")
}
if (FlxG.keys.justPressed("I")) {
trollBig = !trollBig;
showText("Trolls " + (trollBig ? "big." : "normal."));
}
if (FlxG.keys.justPressed('A')) {
progressAll();
showText("Full progress")
}
if (FlxG.keys.justPressed("R")){
spawnTrolls(2)
showText("Spawned 2 trolls")
}
if (FlxG.keys.justPressed("P")){
phasesPaused = !phasesPaused;
showText("Phases " + (phasesPaused ? "paused" : "resumed"))
}
if (FlxG.keys.justPressed("ENTER")){
setWeatherFromInput();
}
if (FlxG.keys.justPressed("C")){
(player as Player).coins += 1;
showText((player as Player).coins + " coins.")
}
if (FlxG.keys.justPressed("ONE")){
// setProgress('D1 A2 X1000 B2 P0 F0 H0 W000011 C0 G7 S00');
}
if (FlxG.keys.justPressed("TWO")){
// setProgress('D2 A7 X1000 B2 P0 F1 H2 W000011 C0 G4 S00');
}
if (FlxG.keys.justPressed("THREE")){
setProgress('D3 A12 X1713 B2 P0 F2 H4 W010011 C1 S01 G3');
}
if (FlxG.keys.justPressed("FOUR")){
setProgress('D4 A17 X1932 B2 P1 F3 H6 W220021 C1 S02 G7');
}
if (FlxG.keys.justPressed("FIVE")){
setProgress('D5 A21 X1899 B4 P1 F3 H6 W010031 C2 S00 G0');
}
if (FlxG.keys.justPressed("SIX")){
setProgress('D6 A25 X2235 B2 P2 F1 H10 W010031 C2 S11 G0');
}
if (FlxG.keys.justPressed("SEVEN")){
setProgress('D7 A29 X2146 B2 P5 F2 H8 W030031 C2 S00 G0');
}
if (FlxG.keys.justPressed("EIGHT")){
setProgress('D8 A33 X2318 B3 P1 F6 H9 W040011 C2 S01 G2');
}
if (FlxG.keys.justPressed("NINE")){
setProgress('D9 A37 X1467 B2 P1 F6 H7 W140041 C2 S02 G0');
}
}
}
public function phaseFirst():void{
beggars.add( new Citizen (kingdomRight+580, 0));
beggars.add( new Citizen (kingdomRight+600, 0));
minBeggars = 2;
}
public function phaseBeforeNightOne():void{
showText("Night comes, be careful.");
}
public function phaseNightOne():void{
trollStats(24, 1, 20, 999999, false, 16.0); // Nojump
spawnTrolls(2);
if (player.x < GAME_WIDTH / 2){
panTo(trolls.members[0]);
} else {
panTo(trolls.members[1]);
}
showText("They will noodle your stuff away.")
}
// These trolls still won't scale your lowest walls
public function phaseNightTwo():void{
trollStats(26, 1, 20, 2, false, 12.0); //Jump0
spawnTrolls(12);
}
// These WILL scale the lowest walls
public function phaseNightThree():void{
trollStats(26, 1, 30, 2, false, 12.0); // Grunts
spawnTrolls(20);
}
// The trolls are a little tougher now.
public function phaseNightFour():void{
trollStats(26, 3, 30, 2, false, 12.0);
spawnTrolls(24);
}
// They are faster but more chaotic, they might
// break your walls, which will kill you in the next wave.
public function phaseNightFive():void{
trollStats(35, 2, 38, 2, false, 4.0); // Chaotic
spawnTrolls(36);
}
// These trolls will scale the stone walls
public function phaseNightSix():void{
trollStats(30, 3, 45, 2, false, 10.0);
spawnTrolls(8);
}
// Boss wave trolls
public function phaseNightSeven():void{
// trollMaxSpeed = 30;
// trollHealth = 1
// spawnTrolls(32);
trollStats(20, 30, 10, 999999, true, 16.0)
spawnTrolls(2);
}
// Since the boss probably broke your walls
// these trolls jump very high, there is no
// disadvantage to not having walls.
// You will need them back in the next wave though.
public function phaseNightEight():void{
trollStats(40, 4, 50, 3, false, 12.0)
spawnTrolls(16);
}
// You need the highest walls here
public function phaseNightNine():void{
trollStats(30, 4, 45, 4, false, 8.0)
spawnTrolls(24);
}
// Kill the player off
public function phaseNightTen():void{
trollStats(20, 30, 10, 999999, true, 16.0); // Boss
spawnTrolls(4);
trollStats(30, 4, 45, 4, false, 8.0); // Strong
spawnTrolls(20);
trollStats(40, 2, 50, 3, false, 12.0); // Jumper
spawnTrolls(10);
trollStats(26, 1, 30, 2, false, 12.0); // Grunts
spawnTrolls(40);
}
public function phaseNightCycle():void{
var difficulty:Number = day.value - 10;
trollStats(30, 3 + 2 * difficulty, 45, 4, false, 8.0); // Strong
spawnTrolls(int(10 + difficulty));
if (day.value % 2 == 0){
trollStats(20, 30, 10, 999999, true, 16.0); // Boss
spawnTrolls(int(2 * difficulty));
}
}
public const PHASES:Array = [
// INTRO (0-3)
[WeatherPresets.FOGGY, 10, null, phaseFirst, null],
// ONE (4-9)
[WeatherPresets.DAWN, 25, null, daybreak, null],
[WeatherPresets.SUNNY, 30, null, null, null],
[WeatherPresets.EVENING, 20, null, null, null],
[WeatherPresets.NIGHT, 20, null, phaseBeforeNightOne, MusicNight2],
[null, 50, null, phaseNightOne, null],
// TWO (10-14)
[WeatherPresets.DAWNLIGHTPINK, 20, null, daybreak, null],
[WeatherPresets.DAYWINDYCLEAR, 30, null, null, MusicDay1],
[WeatherPresets.DUSKYELLOW, 20, null, null, null],
[WeatherPresets.EVENINGORANGE, 20, null, null, MusicNight3],
[WeatherPresets.NIGHTGREEN, 60, 30, phaseNightTwo, null], // GREEN
// THREE (15-18)
[WeatherPresets.DAWNGREY, 20, null, daybreak, null],
[WeatherPresets.DAYBLEAK, 50, null, null, MusicDay2],
[WeatherPresets.DUSKWARM, 20, null, null, null],
[WeatherPresets.EVENINGBLACK, 20, null, null, MusicNight4],
[WeatherPresets.NIGHTDARK, 60, 30, phaseNightThree, null],
// FOUR (19-22)
[WeatherPresets.DAWNBLEAK, 20, null, daybreak, null],
[WeatherPresets.DAYSOFT, 40, null, null, null],
[WeatherPresets.EVENINGMONOTONE, 30, null, null, MusicNight5],
[WeatherPresets.NIGHTSUPERDARK, 65, 30, phaseNightFour, null],
// FIVE (23-26)
[WeatherPresets.DAWNLIGHTPINK, 20, null, daybreak, MusicDay3],
[WeatherPresets.DAYBLEAK, 55, null, null, null],
[WeatherPresets.EVENINGFOGGY, 40, null, null, MusicNight4],
[WeatherPresets.NIGHTFOGGY, 60, 30, phaseNightFive, null],
// SIX (27-30)
[WeatherPresets.DAWNBLEAK, 25, null, daybreak, MusicDay4],
[WeatherPresets.DAYMONOCHROME, 60, null, null, null],
[WeatherPresets.DUSKPINK, 15, null, null, null],
[WeatherPresets.NIGHTCLEAR, 70, 30, phaseNightSix, MusicNight4],
// SEVEN (31-34)
[WeatherPresets.DAWNCLEARORANGE, 20, null, daybreak, null],
[WeatherPresets.DAYCLEARCOLD, 40, null, null, MusicDay3],
[WeatherPresets.DUSKCLEAR, 20, null, null, null],
[WeatherPresets.NIGHTSHINE, 70, 30, phaseNightSeven, MusicNight3],
// EIGHT (35-38)
[WeatherPresets.DAWNREDMOON, 40, null, daybreak, MusicDay5],
[WeatherPresets.DAYORANGESKY, 40, null, null, null],
[WeatherPresets.DUSKFOGGY, 20, null, null, null],
// BIG WAVE
[WeatherPresets.NIGHTPURPLE, 80, 30, phaseNightEight, MusicNight4],
// NINE (39-42)
[WeatherPresets.DAWNBRIGHT, 20, null, daybreak, null],
[WeatherPresets.DAYPASTEL, 75, null, null, MusicDay2],
[WeatherPresets.DUSKTAN, 20, null, null, MusicNight4],
// SINGLE TROLL, MASSIVE HEALTH
[WeatherPresets.NIGHTREDMOON, 60, 30, phaseNightNine, null],
// TEN (43)
[WeatherPresets.DAWNBROWN, 20, null, daybreak, null],
[WeatherPresets.DAYDUSTY, 40, null, null, null],
[WeatherPresets.DUSKRED, 20, null, null, MusicNight3],
// EVERYTHING, YOU DIE HERE.
[WeatherPresets.NIGHTLONG, 60, 30, phaseNightTen, null],
[WeatherPresets.DAWNEARLY, 15, null, trollRetreat, null],
];
public const PHASES_CYCLE:Array = [
[WeatherPresets.DAWNREDMOON, 20, null, daybreak, null],
[WeatherPresets.DAYPASTEL, 40, null, null, null],
[WeatherPresets.DUSKTAN, 20, null, null, null],
[WeatherPresets.NIGHTLONG, 30, null, null, MusicNight5],
[null, 55, null, phaseNightCycle, null]
];
public function nextPhase():void{
if (phasesPaused){
return;
}
var currentPhase:Array;
if (phase < PHASES.length){
currentPhase = PHASES[phase];
} else {
var p:int = (phase - PHASES.length) % 5;
currentPhase = PHASES_CYCLE[p]
}
var weatherTweenTime:Number;
timeToNextPhase = currentPhase[1];
// Transform weather
if (currentPhase[2] == null){
weatherTweenTime = timeToNextPhase * 0.7;
} else {
weatherTweenTime = currentPhase[2]
}
if (currentPhase[0] != null){
weather.tweenTo(currentPhase[0], weatherTweenTime);
}
phase += 1;
// Call the function to do custom actions if there is one
if (currentPhase[3] != null){
currentPhase[3]();
}
// Play music
if (currentPhase[4] != null){
if (this.music != null){
this.music.stop();
}
this.music = FlxG.play(currentPhase[4]);
FlxG.log("Playing " + currentPhase[4]);
}
}
public function updateEnvironmentSounds():void{
var v:Number;
v = 1 - Math.pow(Math.abs(weather.timeOfDay - 0.7) / 0.1, 2);
this.cicada.volume = v;
v = 1 - Math.pow(Math.min(weather.timeOfDay, Math.abs(weather.timeOfDay - 1.0)) / 0.2, 2);
this.owls.volume = v;
v = 1 - Math.pow(Math.abs(weather.timeOfDay - 0.4) / 0.25, 2);
this.birds.volume = v;
// if (v > 0){
// this.cicadas.resume();
// } else {
// this.cicadas.pause();
// }
}
public function trollStats(speed:Number, health:Number, jumpheight:Number, jumpiness:Number=2, big:Boolean=false, confusion:Number=3):void{
trollMaxSpeed = speed;
trollHealth = health;
trollJumpHeight = jumpheight;
trollJumpiness = jumpiness;
trollBig = big;
trollConfusion = confusion;
}
public function spawnTrolls(amount:int):void{
if (cheatNoTrolls)
return;
while(amount){
amount -= 2;
var troll:Troll = (trolls.recycle(Troll) as Troll);
troll.reset(64, groundHeight - 40)
trollsToSpawn.push(troll);
troll = (trolls.recycle(Troll) as Troll);
troll.reset(GAME_WIDTH - 64, groundHeight - 40);
trollsToSpawn.push(troll);
updateTrollSpawn();
}
}
public function updateTrollSpawn():void{
if (trollsToSpawn.length > 0 && trollSpawnTimer <= 0){
(trollsToSpawn.shift() as Troll).go();
(trollsToSpawn.shift() as Troll).go();
trollSpawnTimer = MIN_TROLL_SPAWNTIME;
}
}
public function daybreak():void{
trollRetreat();
(coins.recycle(Coin) as Coin).drop(castle, player);
if (castle.stage >= 2) {
(coins.recycle(Coin) as Coin).drop(castle, player);
}
day.addValue(1);
showCenterText(Utils.toRoman(day.value));
saveProgress();
}
public function saveProgress():void{
var numBeggars:int = beggars.countLiving();
var numCitizens:Array = [0,0,0,0];
for (var i:int = 0; i < characters.length; i ++){
if (characters.members[i] != null && (characters.members[i].alive)){
numCitizens[(characters.members[i] as Citizen).occupation] ++;
}
}
numCitizens[Citizen.HUNTER] += Math.max(0, archers.countLiving());
var wallStages:Array = [];
for (i = 0; i < walls.length; i ++){
wallStages.push((walls.members[i] as Wall).stage);
}
var s:String = '';
s += 'D' + day.value + ' ';
s += 'A' + phase + ' ';
s += 'X' + int(player.x) + ' ';
s += 'B' + numBeggars + ' ';
s += 'P' + numCitizens[Citizen.POOR] + ' ';
s += 'F' + numCitizens[Citizen.FARMER] + ' ';
s += 'H' + numCitizens[Citizen.HUNTER] + ' ';
s += 'W' + wallStages.join('') + ' ';
s += 'C' + castle.stage + ' ';
s += 'S' + (shops.members[0] as Shop).supply + (shops.members[1] as Shop).supply + ' ';
s += 'G' + (player as Player).coins
FlxG.log(s);
savedProgress = s;
}
public function setProgress(s:String):void{
// Parse the string
// 'N1 X1 B2 P0 F0 H0 W000011 C0 G7'
progressAll();
FlxG.flash(0xFFFFFFFF, 3);
FlxG.log("Skip to " + s);
var newDay:int = parseInt(s.match(/D(\d+)/)[1]);
var ph:int = parseInt(s.match(/A(\d+)/)[1]);
var playerX:int = parseInt(s.match(/X(\d+)/)[1]);
var numBeggars:int = parseInt(s.match(/B(\d+)/)[1]);
var numPoor:int = parseInt(s.match(/P(\d+)/)[1]);
var numFarmers:int = parseInt(s.match(/F(\d+)/)[1]);
var numHunters:int = parseInt(s.match(/H(\d+)/)[1]);
var wallStages:Array = s.match(/W(\d)(\d)(\d)(\d)(\d)(\d)/);
var castleStage:int = parseInt(s.match(/C(\d)/)[1]);
var shopSupply:Array = s.match(/S(\d)(\d)/);
var gold:int = parseInt(s.match(/G(\d)/)[1]);
while (beggars.countLiving() < numBeggars){
beggars.add(new Citizen((kingdomRight + kingdomLeft) / 2,0));
}
player.x = playerX;
characters.callAll('kill');
archers.callAll('kill');
var c:Citizen;
while (numPoor) {
c = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);
c.morph(Citizen.POOR);
characters.add(c);
numPoor --;
}
while (numFarmers) {
c = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);
c.morph(Citizen.FARMER);
characters.add(c);
numFarmers --;
}
while (numHunters) {
c = new Citizen ((kingdomRight+kingdomLeft) / 2, 0);
c.morph(Citizen.HUNTER);
characters.add(c);
numHunters --;
}
for (var i:int = 0; i < walls.length; i ++){
(walls.members[i] as Wall).buildTo(parseInt(wallStages[i+1]), true);
}
(shops.members[0] as Shop).setSupply(parseInt(shopSupply[0]));
(shops.members[1] as Shop).setSupply(parseInt(shopSupply[1]));
castle.morph(castleStage);
(player as Player).changeCoins(gold - (player as Player).coins);
phase = ph - 1;
day.setValue(newDay - 1);
nextPhase();
trolls.callAll("kill");
trollsNoCollide.callAll("kill");
gibs.callAll("kill");
}
public function trollRetreat(delay:Number=10):void{
retreatDelay = delay;
if (retreatDelay <= 0){
trollsToSpawn.splice(0);
trolls.callAll("retreat");
trollsNoCollide.callAll("retreat");
}
}
public function pickUpCoin(coin:FlxObject, char:FlxObject):void{
if (char is Player){
(char as Player).pickup(coin);
} else if (char is Citizen){
(char as Citizen).pickup(coin);
} else if (char is Troll){
(char as Troll).pickup(coin);
}
}
public function giveTaxes(char:FlxObject, player:FlxObject):void{
if (char != player){
(char as Citizen).giveTaxes(player as Player);
}
}
public function trollWall(troll:FlxObject, wall:FlxObject):void{
FlxObject.separate(troll, wall);
wall.hurt((troll as Troll).big ? 2 * TROLL_WALL_DAMAGE : TROLL_WALL_DAMAGE);
}
public function trollShot(arrow:FlxObject, troll:Troll):void{
if (troll.alive && arrow.exists){
FlxG.play(HitbigSound).proximity(arrow.x, arrow.y, player, FlxG.width);
arrow.kill();
(troll as Troll).getShot();
}
}
public function bunnyShot(arrow:FlxObject, bunny:FlxObject):void{
if (bunny.alive && arrow.exists){
FlxG.play(HitSound).proximity(arrow.x, arrow.y, player, FlxG.width);
arrow.kill();
(bunny as Bunny).getShot(arrow as Arrow);
}
}
public function trollHit(troll:FlxObject, char:FlxObject):void{
if (char is Citizen){
(char as Citizen).hitByTroll(troll as Troll);
}
if (char == player){
(char as Player).hitByTroll(troll as Troll);
}
}
public function crownStolen():void{
gameover = true;
phasesPaused = true;
trollRetreat(0);
FlxG.mouse.show();
showText("No crown, no king. Game over.");
showText("Click to continue or wait to enter highscore.");
showText("Click to continue or wait to enter highscore.");
FlxG.fade(0, 20, endGame);
}
public function endGame():void{
FlxG.switchState(new GameOverState(day.value - 1));
}
//=== RENDERING ==//
override public function draw():void{
darkness.dirty = true;
darkness.fill(weather.darknessColor);
super.draw();
weather.ambientTransform.applyFilter(FlxG.camera.buffer);
}
public function showCoins():void{
var c:int = (player as Player).coins;
sack.show(c);
}
public function showText(t:String=null):void{
if (t != null){
textQueue = textQueue.concat(t.split('\n'))
}
if (textQueue.length > 0 && textTimeout <= 0){
text.text = textQueue.shift();
text.visible = true;
textTimeout = Math.max(TEXT_MIN_TIME, TEXT_READ_SPEED * text.text.length);
}
}
public function showCenterText(t:String):void{
centerText.text = t;
centerText.visible = true;
centerText.alpha = 0.999;
}
public function panTo(o:FlxSprite, duration:Number=8.0, lead:Number=0):void{
cameraTimeout = duration;
cameraTarget.target = o;
cameraTarget.lead = lead;
}
}
}
================================================
FILE: Player.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxCamera;
import org.flixel.FlxGroup;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSound;
public class Player extends FlxSprite{
[Embed(source='/assets/gfx/king.png')] private var PlayerImg:Class;
[Embed(source="/assets/sound/pickup.mp3")] public static const PickupSound:Class;
[Embed(source="/assets/sound/build.mp3")] private var BuildSound:Class;
[Embed(source="/assets/sound/throw.mp3")] private var ThrowSound:Class;
[Embed(source="/assets/sound/stolen.mp3")] private var StolenSound:Class;
public static var pickupSound:FlxSound = FlxG.loadSound(PickupSound);
public static const BASE_SKIN:uint = 0xFFedbebf;
public static const BASE_DARK:uint = 0xFFbd9898;
public static const BASE_EYES:uint = 0xFFa18383;
public static const MAX_SPEED:Number = 80;
public static const MIN_SPEED:Number = 25;
public static const MAX_FOOD_BONUS:Number = 50;
public static const MAX_FOOD:Number = 100;
public static const HIT_RATE:Number = 0.2;
public static const SELECT_DISTANCE:Number = 10;
private var playstate:PlayState;
private var selectedBuilding:FlxSprite = null;
private var floatCoin:CoinFloat = null;
private var lastMoved:Number = 0;
public var food:Number = 100;
public var hasCrown:Boolean = true;
public var lastTrollHit:Number = 0;
public var coins:int = 7;
public function Player(X:int,Y:int){
super(X,Y);
y = 100 // 132 (land height) - 32 (player height)
loadGraphic(PlayerImg,true,true,64,64);
width = 20;
height = 32;
offset.x = 22;
offset.y = 32;
maxVelocity.x = MAX_SPEED;
drag.x = maxVelocity.x*5;
playstate = (FlxG.state as PlayState);
addAnimation('walk_slow',[0,1,2,3,4,5,6,7],10,true);
addAnimation('walk_fast',[0,1,2,3,4,5,6,7],15,true);
addAnimation('stand',[8],10,true);
addAnimation('eat',[9,10],5,true);
addAnimation('nocrown',[11],10,true);
play('stand');
playstate.player = this;
var d:Number = Math.random() * 20;
var skin:uint = Utils.HSVtoRGB(d, 0.19 + (d / 100), 0.97 - (d / 33));
Utils.replaceColor(pixels, BASE_SKIN, skin);
Utils.replaceColor(pixels, BASE_DARK, Utils.interpolateColor(skin,0xFF000000,0.2));
Utils.replaceColor(pixels, BASE_EYES, Utils.interpolateColor(skin,0xFF000000,0.5));
}
public function changeCoins(amt:int):void{
if (amt > 0) {
pickupSound.play(false);
pickupSound.proximity(x, y, this, FlxG.width);
}
coins += amt;
playstate.showCoins();
}
public function hitByTroll(troll:Troll):void{
if (troll.hasCoin) return;
if (lastTrollHit < HIT_RATE) return;
lastTrollHit = 0;
// If the player has coins, lose one and return.
if (coins > 0){
var c:Coin = (playstate.coins.recycle(Coin) as Coin);
c.drop(this, troll, true);
c.justThrown = true;
FlxG.play(StolenSound).proximity(x, y, this, FlxG.width);
changeCoins(-1);
FlxG.shake();
return;
}
if (hasCrown){
FlxG.flash(0xFFFFFFFF, 0.1);
troll.stealCrown();
lostCrown(troll);
playstate.crownStolen();
}
}
public function lostCrown(troll:FlxObject):void{
hasCrown = false;
facing = troll.x > x ? RIGHT : LEFT;
play('nocrown');
FlxG.play(StolenSound).proximity(x, y, this, FlxG.width);
Utils.explode(this, playstate.gibs);
}
public function pickup(coin:FlxObject):void{
if (!coin.alive) return;
var c:Coin = coin as Coin;
// Return if the coin doesn't belong to me.
if (c.justThrown){
return;
}
c.kill();
changeCoins(1);
}
override public function update():void {
lastTrollHit += FlxG.elapsed;
// Check for movement input
acceleration.x = 0;
if (!hasCrown){
return;
}
if(FlxG.keys.LEFT || FlxG.keys.RIGHT){
lastMoved = 0;
if (food > 0){
food -= FlxG.elapsed;
}
maxVelocity.x = MIN_SPEED + Math.min(1,food/MAX_FOOD_BONUS) * (MAX_SPEED-MIN_SPEED);
if (!playstate.horseAdvice && food < 10){
playstate.horseAdvice = true;
playstate.showText("Horse is tired. Let him rest on the grass.")
}
}
if(FlxG.keys.LEFT){
acceleration.x = -maxVelocity.x*4;
facing = LEFT;
if (maxVelocity.x > MIN_SPEED + 15){
play('walk_fast');
} else {
play('walk_slow');
}
} else if(FlxG.keys.RIGHT){
acceleration.x = maxVelocity.x*4;
facing = RIGHT;
if (maxVelocity.x > MIN_SPEED + 15){
play('walk_fast');
} else {
play('walk_slow');
}
} else {
lastMoved += FlxG.elapsed;
if (lastMoved > 1 && food < MAX_FOOD){
// Check if on grass
var headPos:Number = (x+width/2) + (facing == RIGHT ? 25: -25)
var onTile:int = playstate.floor.getTile(headPos/32,4)
if ((onTile >= 7 && onTile <= 11) || (onTile >= 17 && onTile <= 18)){
play('eat',false);
food += FlxG.elapsed*10;
} else {
play('stand');
}
} else {
play('stand');
}
}
if (FlxG.keys.SHIFT && PlayState.CHEATS) {
velocity.x *= 10
}
if (FlxG.keys.justPressed("DOWN")){
if (coins <= 0){
playstate.showCoins();
} else {
if (selectedBuilding != null){
changeCoins(-1);
giveCoin(selectedBuilding);
} else {
var cit:Citizen;
var closestCitizen:Citizen = null;
var closest:Number = 1000000;
for (var i:int = 0; i < playstate.beggars.length; i++){
cit = (playstate.beggars.members[i] as Citizen)
if (Math.abs((cit.x + cit.width/2) - (x + width/2)) < closest){
closestCitizen = cit;
closest = Math.abs((cit.x + cit.width/2) - (x + width/2));
}
}
if (playstate.recruitedCitizen || closest < 64){
var c:Coin = (playstate.coins.recycle(Coin) as Coin);
c.drop(this, closestCitizen);
c.justThrown = true;
FlxG.play(ThrowSound).proximity(x, y, this, FlxG.width);
changeCoins(-1);
}
}
}
}
super.update();
//Find selected shop/wall
if (selectedBuilding != null){
if (Math.abs((selectedBuilding.x + selectedBuilding.width/2) - (x + width/2)) > SELECT_DISTANCE * 2){
deselect(selectedBuilding);
}
} else if (playstate.recruitedCitizen) {
checkSelectable(playstate.objects)
checkSelectable(playstate.shops);
checkSelectable(playstate.walls);
}
// CAP WALKING AT LEVEL ENDS
if (x < 0){
velocity.x = Math.max(velocity.x, 0);
} else if (x + width > PlayState.GAME_WIDTH) {
velocity.x = Math.min(velocity.x, 0);
}
}
private function checkSelectable(group:FlxGroup):void{
for (var i:int = 0; i < group.length; i ++){
var b:FlxSprite = group.members[i];
if (b != null && Math.abs((b.x + b.width/2) - (x + width/2)) <= SELECT_DISTANCE){
if ((b as Buildable).canBuild())
select(b);
}
}
}
private function select(building:FlxSprite):void{
selectedBuilding = building;
if (floatCoin == null){
playstate.add(floatCoin = new CoinFloat());
}
floatCoin.visible = true;
floatCoin.float(selectedBuilding);
}
private function deselect(building:FlxSprite):void{
selectedBuilding.color = 0xFFFFFFFF;
selectedBuilding = null;
floatCoin.visible = false;
}
private function giveCoin(building:FlxSprite):void{
Buildable(building).build();
FlxG.play(BuildSound).proximity(x, y, this, FlxG.width);
deselect(building);
}
}
}
================================================
FILE: Preloader.as
================================================
package
{
import org.flixel.system.FlxPreloader;
public class Preloader extends FlxPreloader
{
public function Preloader()
{
className = "king";
super();
}
}
}
================================================
FILE: Reed.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Reed extends FlxSprite{
[Embed(source='/assets/gfx/reed.png')] private var ReedImg:Class;
private var weather:Weather;
private var weatherChanged:Number = 0;
private var t:Number = 0;
public function Reed(X:int, Y:int){
super(X,Y);
loadGraphic(ReedImg, true, false, 32, 32);
this.weather = (FlxG.state as PlayState).weather;
}
override public function update():void{
t += weather.wind;
frame = int(3 * (0.5 + 0.5*Math.sin(0.05*t + x)) + 0.3 * Math.sin(0.2*t));
/*if (weather.changed > weatherChanged) {
weatherChanged = weather.t;
var wind:Number = weather.wind;
wind = wind * (0.5 + 0.5*Math.sin(x + weather.t*wind*3) + 0.3*Math.sin(x + weather.t*wind*5));
frame = int(3*(1-wind))
}*/
}
}
}
================================================
FILE: Scaffold.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxGroup;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Scaffold extends FlxSprite{
[Embed(source='/assets/gfx/scaffold.png')] public var Img:Class;
public function Scaffold(){
super(0,0);
loadGraphic(Img);
offset.x = 4;
width = 24;
}
public function build(over:FlxSprite):Scaffold {
revive();
x = over.x;
y = over.y;
return this;
}
}
}
================================================
FILE: Shop.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxGroup;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Shop extends FlxSprite implements Buildable{
[Embed(source='/assets/gfx/shop.png')] public var Img:Class;
public static const SCYTHES:int = 1;
public static const BOWS:int = 2;
public var type:int;
public var supply:int = 0;
public function Shop(X:int, Y:int){
super(X,Y+2);
if (X > PlayState.GAME_WIDTH/2){
type = BOWS;
} else {
type = SCYTHES;
}
loadGraphic(Img,true);
width = 56;
offset.x = 4;
x += 4;
height = 46;
offset.y = 18;
y += 18;
moves = false;
updateAppearance();
}
override public function update():void{
if (supply > 0){
FlxG.overlap(this, (FlxG.state as PlayState).characters, equip)
}
}
public function equip(shop:FlxObject, char:FlxObject):void{
if (supply <= 0)
return;
var cit:Citizen = char as Citizen;
if (cit.occupation == Citizen.POOR){
supply --;
if (type == BOWS){
cit.morph(Citizen.HUNTER);
} else {
cit.morph(Citizen.FARMER);
}
updateAppearance();
}
}
public function setSupply(s:int):void{
supply = s;
updateAppearance();
}
public function updateAppearance():void{
frame = supply;
if (type == BOWS){
frame += 5;
}
}
public function canBuild():Boolean{
return (supply < 4);
}
public function build():void{
(FlxG.state as PlayState).boughtItem = true;
supply += 1;
flicker(0.3);
updateAppearance();
}
}
}
================================================
FILE: Sky.as
================================================
package{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class Sky extends FlxSprite{
private var weather:Weather;
private var weatherChanged:Number = 0;
public function Sky(weather:Weather):void{
this.weather = weather;
scrollFactor.x = scrollFactor.y = 0;
makeGraphic(FlxG.width,FlxG.height,0x00000000,true);
}
override public function update():void{
if (weather.changed > weatherChanged) {
Utils.gradientOverlay(pixels, [weather.sky, weather.horizon, weather.haze],90, 1);
dirty = true;
weatherChanged = weather.t;
}
}
}
}
================================================
FILE: Sparkle.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxParticle;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
public class Sparkle extends FlxParticle{
[Embed(source='/assets/gfx/sparkle.png')] private var Img:Class;
public function Sparkle(){
super();
loadGraphic(Img,true);
addAnimation('splash',[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],30,false);
}
override public function reset(X:Number, Y:Number):void{
super.reset(X,Y);
lifespan = 1.0;
play('splash', true);
}
}
}
================================================
FILE: Splash.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxParticle;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
public class Splash extends FlxParticle{
[Embed(source='/assets/gfx/splash.png')] private var Img:Class;
public function Splash(){
super();
loadGraphic(Img,true);
addAnimation('splash',[0,1,2,3,4],10);
}
override public function reset(X:Number, Y:Number):void{
super.reset(X,Y);
lifespan = 0.5;
play('splash');
}
}
}
================================================
FILE: SunMoon.as
================================================
package{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class SunMoon extends Light{
[Embed(source='/assets/gfx/sunmoon.png')] public var Img:Class;
[Embed(source='/assets/gfx/light_mid.png')] private var LightMidImg:Class;
[Embed(source='/assets/gfx/light_reflect_wide.png')] private var LightReflectWideImg:Class;
public static const ZENITH:Number = 20 // Highest point
public static const HORIZON:Number = 100 // Sun "extinguishes" below horizon
private var weatherChanged:Number = 0;
public function SunMoon(weather:Weather):void{
super(0,0);
offset.x = offset.y = 16;
scrollFactor.x = scrollFactor.y = 0.0;
loadGraphic(Img,true);
beam.loadGraphic(LightMidImg);
reflected.loadGraphic(LightReflectWideImg);
reflected.color = 0xFFfc8f53;
beam.blend = 'screen';
}
override public function update():void{
/**
* the timeOfDay works as follows:
* 0 and 1 are night. 0.5 is mid-day.
*/
if (weather.changed > weatherChanged) {
var progressX:Number = (weather.timeOfDay*2+0.5)%1;
var progressY:Number = Math.sin(Math.PI*progressX)
x = width + (FlxG.width - 2*width) * progressX;
y = HORIZON - progressY*(HORIZON-ZENITH);
color = weather.sunTint;
beam.alpha = progressY * 2;
frame = (weather.timeOfDay > 0.25 && weather.timeOfDay < 0.75) ? 0 : 1;
dirty = true;
beam.drawFrame(true);
weatherChanged = weather.t;
}
super.update();
}
}
}
================================================
FILE: Torch.as
================================================
package{
import org.flixel.FlxSprite;
import org.flixel.FlxG;
public class Torch extends Light{
[Embed(source='/assets/gfx/torch.png')] private var TorchImg:Class;
[Embed(source='/assets/gfx/light_mid.png')] private var LightMidImg:Class;
[Embed(source='/assets/gfx/light_reflect_small.png')] private var LightReflectSmallImg:Class;
public function Torch(X:Number, Y:Number){
Y += 8;
super(X,Y);
offset.x = width/2;
offset.y = 8;
loadGraphic(TorchImg, true, true, 16, 32);
beam.loadGraphic(LightMidImg);
reflected.loadGraphic(LightReflectSmallImg);
reflected.color = 0xFFfc8f53;
if (FlxG.random()<0.5){
addAnimation('on', [0,1,2,3,4,5,6,7], 6, true);
} else {
addAnimation('on', [8,9,10,11,12,13,14,15], 6, true);
}
facing = (FlxG.random() < 0.5) ? LEFT : RIGHT;
addAnimationCallback(this.dim);
play('on');
setLight();
}
override public function update():void{
if (x < playstate.kingdomRight + 64 && x > playstate.kingdomLeft - 64){
visible = true;
} else {
visible = false;
}
super.update()
}
}
}
================================================
FILE: Treeline.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Treeline extends FlxSprite{
[Embed(source='/assets/gfx/treeline.png')] private var TreelineImg:Class;
public function Treeline(X:int, Y:int){
super(X,Y);
loadGraphic(TreelineImg, false, true, 96, 160);
if (X == 0)
facing = LEFT;
}
}
}
================================================
FILE: Troll.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxCamera;
public class Troll extends FlxSprite{
[Embed(source='/assets/gfx/troll.png')] private var Img:Class;
[Embed(source='/assets/gfx/trollbig.png')] private var ImgBig:Class;
public var t:Number = 0;
public var goal:Number = 1600;
public var hasCoin:Boolean = false;
public var hasCrown:Boolean = false;
public var wait:Boolean = false;
public var retreating:Boolean = false;
public var maxSpeed:Number = 20;
public var jumpHeight:Number = 100;
public var jumpiness:Number = 0.01;
public var confusion:Number = 0.01;
public var big:Boolean = false;
public var safeDistance:Number = 200;
private var maxHeightReached:Number = 0;
private var jumpCooldown:Number = 0;
private var confuseCooldown:Number = 0;
private var playstate:PlayState;
public function Troll(){
super(0,0);
maxVelocity.y = 275;
maxVelocity.x = 60;
acceleration.y = 900;
loadAnims();
playstate = (FlxG.state as PlayState);
// allowCollisions = UP|DOWN;
}
override public function reset(X:Number,Y:Number):void{
retreating = false;
hasCoin = false;
wait = true;
visible = false;
velocity.x = velocity.y = 0;
if (! big == playstate.trollBig){
big = playstate.trollBig;
loadAnims();
}
X -= width / 2;
super.reset(X - width / 2, Y);
health = playstate.trollHealth;
maxSpeed = playstate.trollMaxSpeed;
jumpHeight = playstate.trollJumpHeight;
jumpiness = playstate.trollJumpiness;
jumpCooldown = jumpiness + Math.random() * 2 * jumpiness;
confusion = playstate.trollConfusion;
confuseCooldown = confusion + Math.random() * 2 * confusion;
t = 1;
if (playstate.trollsNoCollide.remove(this)){
playstate.trolls.add(this);
}
}
private function loadAnims():void{
if (big){
// scale.x = scale.y = 2;
loadGraphic(ImgBig,true,true,64,64);
offset.x = 24;
offset.y = 24;
width = 16;
height = 40;
addAnimation('walk',[0,1,2,3,4,5,6,7,8], 7, true);
addAnimation('walk_crown',[9,10,11,12,13,14,15,16,17], 7, true);
addAnimation('stand',[0],10,true);
} else {
// scale.x = scale.y = 1;
loadGraphic(Img,true,true,32,32);
offset.x = 12;
offset.y = 12;
width = 8;
height = 20;
addAnimation('walk',[0,1,2,3,4,5,6,7,8],(10+FlxG.random()*5),true);
addAnimation('walk_crown',[9,10,11,12,13,14,15,16,17],(10+FlxG.random()*5),true);
addAnimation('walk_coin',[18,19,20,21,22,23,24,25,26],(10+FlxG.random()*5),true);
addAnimation('stand',[0],10,true);
}
}
public function getsCoin():void{
hasCoin = true;
retreat();
}
public function pickup(coin:FlxObject):void{
if (!hasCoin && coin.alive && !retreating && !big){
coin.kill();
hasCoin = true;
retreat();
}
}
public function stealCrown():void{
hasCrown = true;
playstate.panTo(this, 20);
retreat();
}
public function getShot():void{
if (hasCrown) return;
health --;
if (health > 0) {
// flicker();
} else {
Utils.explode(this, playstate.gibs, 1.0);
if (hasCoin) {
(playstate.coins.recycle(Coin) as Coin).drop(this);
}
kill();
}
}
override public function kill():void{
playstate.trollsNoCollide.remove(this);
playstate.trolls.add(this);
super.kill();
}
public function retreat():void{
retreating = true;
goal = (x < playstate.player.x) ? 0 : FlxG.worldBounds.width;
wait = false;
playstate.trolls.remove(this);
playstate.trollsNoCollide.add(this);
}
public function go():void{
wait = false;
visible = true;
goal = playstate.player.x;
if (big) {
playstate.trolls.remove(this);
playstate.trollsNoCollide.add(this);
}
}
override public function update():void {
if (wait){
acceleration.x = 0;
velocity.x = 0;
return;
}
confuseCooldown -= FlxG.elapsed;
jumpCooldown -= FlxG.elapsed;
// Check for movement input
acceleration.x = 0;
t += FlxG.elapsed;
if (!hasCoin && t > 1.8){
if (retreating || confuseCooldown < 0){
goal = (x < playstate.player.x) ? 0 : FlxG.worldBounds.width;
confuseCooldown = confusion + Math.random() * 2 * confusion;
} else {
goal = playstate.player.x;
}
t = 0
}
// I don't know why I need this, but apparently trolls can fall of the world.
if (x <= 24 || x + width >= FlxG.worldBounds.width - 24){
if (retreating) kill();
}
if (y > 200){
// throw new Error("TROLL FELL OFF :(");
FlxG.log("TROLL FELL " + x + " , " + y)
FlxG.log("Retreating: " + retreating);
FlxG.log("Big: " + big);
FlxG.log("Wait: " + wait);
kill();
}
facing = (goal > x) ? RIGHT : LEFT;
if(touching & FLOOR){
maxVelocity.x = maxSpeed;
// Sprint outside of kingdom.
if (x > playstate.kingdomRight + safeDistance || x < playstate.kingdomLeft - safeDistance){
maxVelocity.x += 40;
}
drag.x = maxVelocity.x*10;
if(facing == LEFT){
acceleration.x = -maxVelocity.x*4;
} else {
acceleration.x = maxVelocity.x*4;
}
if (hasCrown)
play('walk_crown');
else if (hasCoin)
play('walk_coin');
else
play('walk')
// Jump
if(jumpCooldown < 0){
maxHeightReached = 0;
var v:Number = Math.sqrt(jumpHeight * 2 * acceleration.y)
velocity.y = -v;
maxVelocity.x = maxSpeed * 2;
velocity.x *= 2
jumpCooldown = jumpiness + Math.random() * 2 * jumpiness;
}
} else {
maxHeightReached = Math.max(112 - y, maxHeightReached)
drag.x = maxVelocity.x*0.1;
maxVelocity.x = maxSpeed * 2;
if(facing == LEFT)
acceleration.x = -maxVelocity.x;
else
acceleration.x = maxVelocity.x;
}
super.update();
}
}
}
================================================
FILE: Utils.as
================================================
package
{
import flash.display.BitmapData;
import flash.display.Shape;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import org.flixel.FlxPoint;
import org.flixel.FlxSprite;
import org.flixel.FlxParticle;
import org.flixel.FlxGroup;
import org.flixel.FlxG;
public class Utils{
public static const DEG_TO_RAD:Number = Math.PI/180;
public static var ROMAN_VALUES:Array = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
public static var ROMAN_LETTERS:Array = ['M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I']
/**
* Shrinks the hitbox (x,y and offset) of given FlxSprite to the pixels that are actually
* covered by a greater portion than min{X,Y}Cover of the pixels.
*/
static public function shrinkHitbox(sprite:FlxSprite, minXCover:Number=0, minYCover:Number=0.5):void{
var pix:BitmapData = sprite.pixels;
var x:int, y:int, sum:int = 0;
var minx:int = pix.width;
var maxx:int = 0;
var miny:int = pix.height;
var maxy:int = 0;
for (x = 0; x < pix.width; x++){
sum = 0
for (y = 0; y < pix.height; y++){
if (pix.getPixel32(x,y) > 0x00FFFFFF) sum ++;
}
if (sum >= minXCover*pix.height) {
minx = Math.min(minx,x);
maxx = Math.max(maxx,x);
}
}
for (y = 0; y < pix.height; y++){
sum = 0
for (x = 0; x < pix.width; x++){
if (pix.getPixel32(x,y) > 0x00FFFFFF) sum ++;
}
if (sum >= minYCover*pix.width) {
miny = Math.min(miny,y);
maxy = Math.max(maxy,y);
}
}
sprite.width = maxx-minx;
sprite.height = maxy-miny;
sprite.offset.x = minx
sprite.offset.y = miny;
sprite.x += minx/2;
sprite.y += miny/2;
}
static public function findRectanglesWithColor(bitmap:BitmapData, color:uint):Vector.<Rectangle> {
var cur:Rectangle;
var rects:Vector.<Rectangle> = new Vector.<Rectangle>();
var i:int,j:int,k:int;
for(i = 0; i < bitmap.height; i++){
for(j = 0; j < bitmap.width; j++){
for(k = 0; k < rects.length; k++){
cur = rects[k];
// If we are in a rect, skip to the right side.
if (cur.contains(j,i)){
j = cur.right;
// If we are outside of the image, next line.
if (j >= bitmap.width){
j = 0;
i++;
}
}
}
if (bitmap.getPixel32(j,i) == color){
rects.push(cur = new Rectangle(j,i,1,1));
// Traverse to right
while( bitmap.getPixel32(j,i) == color){
j++;
}
cur.width = j - cur.x;
// Traverse down
while( bitmap.getPixel32(j-1,i) == color){
i++;
}
cur.height = i - cur.y;
// Reset I and J
j = cur.right;
i = cur.y;
}
}
}
return rects;
}
/**
* Replace one color with another in bitmap.
*/
static public function replaceColor(bitmap:BitmapData,fromColor:uint, toColor:uint):void{
for (var i:int = 0; i < bitmap.height; i++){
for( var j:int = 0; j < bitmap.width; j++){
if (bitmap.getPixel32(j,i) == fromColor){
bitmap.setPixel32(j, i, toColor);
}
}
}
}
/**
* Fills a bitmap with a gradient with given colors
*/
static public function gradientOverlay(bitmap:BitmapData, colors:Array, rotation:Number=90, chunks:int = 1):void{
var matrix:Matrix = new Matrix();
matrix.createGradientBox(bitmap.width/chunks, bitmap.height/chunks, rotation*DEG_TO_RAD);
var s:Shape = new Shape();
var ratios:Array = new Array(colors.length);
var alphas:Array = new Array(colors.length);
for (var i:int = 0; i < colors.length; i ++){
alphas[i] = (colors[i] >>> 24)/255;
ratios[i] = (i * (1/(colors.length-1)))*255;
}
s.graphics.beginGradientFill("linear", colors, alphas, ratios, matrix, "pad", "rgb");
s.graphics.drawRect(0, 0, bitmap.width/chunks, bitmap.height/chunks);
if (chunks == 1) {
bitmap.draw(s);
} else {
var transform:Matrix = new Matrix();
var tempBitmap:BitmapData = new BitmapData(bitmap.width/chunks,bitmap.height/chunks,true,0x000000);
tempBitmap.draw(s);
transform.scale(bitmap.width/tempBitmap.width,bitmap.height/tempBitmap.height);
bitmap.draw(tempBitmap,transform);
}
}
/**
* Convert a HSV (hue, saturation, lightness) color space value to an RGB color
*
* @param h Hue degree, between 0 and 359
* @param s Saturation, between 0.0 (grey) and 1.0
* @param v Value, between 0.0 (black) and 1.0
*
* @return 32-bit RGB colour value (0xAARRGGBB)
*/
public static function HSVtoRGB(h:Number, s:Number, v:Number):uint
{
var result:uint;
if (s == 0.0)
{
result = getColor32(255, v * 255, v * 255, v * 255);
}
else
{
h = h / 60.0;
var f:Number = h - int(h);
var p:Number = v * (1.0 - s);
var q:Number = v * (1.0 - s * f);
var t:Number = v * (1.0 - s * (1.0 - f));
switch (int(h))
{
case 0:
result = getColor32(255, v * 255, t * 255, p * 255);
break;
case 1:
result = getColor32(255, q * 255, v * 255, p * 255);
break;
case 2:
result = getColor32(255, p * 255, v * 255, t * 255);
break;
case 3:
result = getColor32(255, p * 255, q * 255, v * 255);
break;
case 4:
result = getColor32(255, t * 255, p * 255, v * 255);
break;
case 5:
result = getColor32(255, v * 255, p * 255, q * 255);
break;
default:
FlxG.log("FlxColor Error: HSVtoRGB : Unknown color");
}
}
return result;
}
public static function RGBtoHSV(color:uint):Object
{
var rgb:Object = getRGB(color);
var red:Number = rgb.red / 255;
var green:Number = rgb.green / 255;
var blue:Number = rgb.blue / 255;
var min:Number = Math.min(red, green, blue);
var max:Number = Math.max(red, green, blue);
var delta:Number = max - min;
var lightness:Number = (max + min) / 2;
var hue:Number;
var saturation:Number;
// Grey color, no chroma
if (delta == 0)
{
hue = 0;
saturation = 0;
}
else
{
if (lightness < 0.5)
{
saturation = delta / (max + min);
}
else
{
saturation = delta / (2 - max - min);
}
var delta_r:Number = (((max - red) / 6) + (delta / 2)) / delta;
var delta_g:Number = (((max - green) / 6) + (delta / 2)) / delta;
var delta_b:Number = (((max - blue) / 6) + (delta / 2)) / delta;
if (red == max)
{
hue = delta_b - delta_g;
}
else if (green == max)
{
hue = (1 / 3) + delta_r - delta_b;
}
else if (blue == max)
{
hue = (2 / 3) + delta_g - delta_r;
}
if (hue < 0)
{
hue += 1;
}
if (hue > 1)
{
hue -= 1;
}
}
// Keep the value with 0 to 359
hue *= 360;
hue = Math.round(hue);
// Testing
//saturation *= 100;
//lightness *= 100;
return { hue: hue, saturation: saturation, lightness: lightness, value: lightness };
}
public static function interpolateColor(color1:uint, color2:uint, f:Number):uint
{
var a1:uint = color1 >>> 24;
var r1:uint = color1 >> 16 & 0xFF;
var g1:uint = color1 >> 8 & 0xFF;
var b1:uint = color1 & 0xFF;
var a2:uint = color2 >>> 24;
var r2:uint = color2 >> 16 & 0xFF;
var g2:uint = color2 >> 8 & 0xFF;
var b2:uint = color2 & 0xFF;
var fi:Number = (1-f);
a1 = (fi * a1) + (f * a2);
r1 = (fi * r1) + (f * r2);
g1 = (fi * g1) + (f * g2);
b1 = (fi * b1) + (f * b2);
return a1 << 24 | r1 << 16 | g1 << 8 | b1;
}
public static function interpolateColorAndAlpha(color1:uint, color2:uint, steps:uint, currentStep:uint):uint
{
var src1:Object = getRGB(color1);
var src2:Object = getRGB(color2);
var a:uint = (((src2.alpha - src1.alpha) * currentStep) / steps) + src1.alpha;
var r:uint = (((src2.red - src1.red) * currentStep) / steps) + src1.red;
var g:uint = (((src2.green - src1.green) * currentStep) / steps) + src1.green;
var b:uint = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue;
return getColor32(a, r, g, b);
}
/**
* Return the component parts of a color as an Object with the properties alpha, red, green, blue
*
* <p>Alpha will only be set if it exist in the given color (0xAARRGGBB)</p>
*
* @param color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB)
*
* @return Object with properties: alpha, red, green, blue
*/
public static function getRGB(color:uint):Object
{
var alpha:uint = color >>> 24;
var red:uint = color >> 16 & 0xFF;
var green:uint = color >> 8 & 0xFF;
var blue:uint = color & 0xFF;
return { alpha: alpha, red: red, green: green, blue: blue };
}
/**
* Given an alpha and 3 color values this will return an integer representation of it
*
* @param alpha The Alpha value (between 0 and 255)
* @param red The Red channel value (between 0 and 255)
* @param green The Green channel value (between 0 and 255)
* @param blue The Blue channel value (between 0 and 255)
*
* @return A native color value integer (format: 0xAARRGGBB)
*/
public static function getColor32(alpha:uint, red:uint, green:uint, blue:uint):uint
{
return alpha << 24 | red << 16 | green << 8 | blue;
}
public static function explode(object:FlxSprite, group:FlxGroup, portion:Number = 1, gibsize:int=4, rounded:Boolean=true):Vector.<FlxParticle>{
var gibs:Vector.<FlxParticle> = new Vector.<FlxParticle>()
var gib:FlxParticle;
for (var x:int = 0; x < object.framePixels.width; x += gibsize){
for (var y:int = 0; y < object.framePixels.height; y += gibsize){
if ((object.framePixels.getPixel32(x+gibsize/2,y+gibsize/2) >>> 24) > 0){
if (FlxG.random() < portion){
gib = group.recycle(FlxParticle) as FlxParticle;
if (gib.frameWidth != gibsize || gib.frameHeight != gibsize){
gib.makeGraphic(gibsize,gibsize,0,true);
}
gib.revive();
// _flashPoint.x = X;
// _flashPoint.y = Y;
// _flashRect2.width = bitmapData.width;
// _flashRect2.height = bitmapData.height;
// gib.framePixels.copyPixels(object._framePixels,rect,point,null,null,true);
gib.stamp(object, -x, -y);
if (rounded){
gib.framePixels.setPixel32(0,0,0);
gib.framePixels.setPixel32(0,gibsize-1,0);
gib.framePixels.setPixel32(gibsize-1,0,0);
gib.framePixels.setPixel32(gibsize-1,gibsize-1,0);
}
gibs.push(gib);
gib.elasticity = 0.5;
gib.lifespan = 7;
gib.x = object.x - object.offset.x + x;
gib.y = object.y - object.offset.y + y;
gib.acceleration.y = 900;
gib.velocity.x = FlxG.random()*80 - 40;
gib.velocity.y = -130-FlxG.random()*30;
}
}
}
}
return gibs;
}
/**
* Returns a roman numeral string
*/
public static function toRoman(n:int):String{
var s:String = ''
for (var i:int = 0; i < ROMAN_LETTERS.length; i ++){
var c:int = Math.floor(n / ROMAN_VALUES[i])
n -= c * ROMAN_VALUES[i];
while (c > 0){
s += ROMAN_LETTERS[i];
c --;
}
}
return s;
}
}
}
================================================
FILE: Wall.as
================================================
package
{
import flash.geom.Point;
import org.flixel.FlxSprite;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
public class Wall extends FlxSprite implements Workable, Buildable{
[Embed(source='/assets/gfx/wall.png')] private var WallImg:Class;
[Embed(source="/assets/sound/hitwall.mp3")] private var HitwallSound:Class;
public const HEIGHT:Array = [11,38,46,54,59]; // Effective Height: [26, 34, 42, 47]
public const HEALTH:Array = [2,38,50,60,75];
public const HURT_COOLDOWN:Number = 1;
public const WORK_BUILD_HEIGHT:int = 10;
public const WORK_HEAL_AMOUNT:int = 4;
private var playstate:PlayState;
public var scaffold:Scaffold = null;
public var building:Boolean = false;
public var heightToBuild:int = 0;
public var baseY:Number;
public var stage:int = 0;
private var t:Number = 0;
public function Wall(X:Number, Y:Number){
baseY = Y;
super(X,Y);
immovable = true;
moves = false;
solid = false;
loadGraphic(WallImg, true, true, 32, 64);
addAnimation("grow",[0,1,2,3,4,5,6,7,8,9],1);
if (X > 1920){
facing = LEFT;
}
offset.x = 4;
width = 24;
health = HEALTH[stage];
updateAppearance();
playstate = FlxG.state as PlayState;
}
public function build():void{
buildTo(stage + 1);
}
public function buildTo(s:int, instant:Boolean=false):void{
if (!instant && s < stage) return;
building = true;
stage = s;
heightToBuild = HEIGHT[stage];
health = HEALTH[stage];
updateAppearance();
if (scaffold != null){
scaffold.kill();
}
scaffold = (playstate.indicators.recycle(Scaffold) as Scaffold).build(this);
scaffold.y = y - HEIGHT[stage];
solid = false;
// Kind of hacky this.
if (instant){
heightToBuild = 1;
work(null);
}
// flicker();
}
public function work(citizen:Citizen=null):void{
if (heightToBuild > 0) {
heightToBuild -= WORK_BUILD_HEIGHT;
if (heightToBuild <= 0){
heightToBuild = 0;
building = false;
solid = true;
Utils.explode(scaffold, playstate.gibs, 1);
scaffold.kill();
scaffold = null;
}
} else {
if (health < HEALTH[stage]){
health += Math.min(WORK_HEAL_AMOUNT, HEALTH[stage] - health);
}
}
updateAppearance();
}
override public function hurt(Damage:Number):void{
if (t > HURT_COOLDOWN){
health -= Damage;
FlxG.play(HitwallSound).proximity(x, y, playstate.player, FlxG.width)
Utils.explode(this, playstate.gibs, 0.1);
t = 0;
}
if (health <= 0 && stage > 0){
Utils.explode(this, playstate.gibs, 1.0);
stage = 0;
health = HEALTH[stage];
}
health = Math.max(health, HEALTH[0]);
updateAppearance();
}
public function needsWork():Boolean{
return ((building || health < HEALTH[stage]) && t < HURT_COOLDOWN);
}
public function canBuild():Boolean{
return (!building && stage < 4)
}
private function updateAppearance():void{
height = HEIGHT[stage] - heightToBuild;
y = baseY + 64 - height;
offset.y = 64 - HEIGHT[stage];
if (health < HEALTH[stage] / 2){
frame = stage + 5;
} else {
frame = stage;
}
}
override public function update():void{
t += FlxG.elapsed;
if (this.stage > 0 && !building){
if (this.x > PlayState.GAME_WIDTH/2){
playstate.kingdomRight = Math.max(playstate.kingdomRight, x)
} else {
playstate.kingdomLeft = Math.min(playstate.kingdomLeft, x+width)
}
}
}
}
}
================================================
FILE: Water.as
================================================
package
{
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.filters.DisplacementMapFilter;
import flash.filters.DisplacementMapFilterMode;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
import org.flixel.FlxSprite;
import org.flixel.FlxGroup;
import org.flixel.FlxG;
public class Water extends FlxSprite
{
public static const NOISE_BIAS:int = 100;
public static const WIND_RIPPLE_MULTIPLIER:Number = 25;
private var rect:Rectangle = new Rectangle(0, 0, 480, 160);
//private var point:Point = new Point(0, 160);
private var zeroPoint:Point = new Point(0, 0);
private var perlinOffset:Point = new Point(0,0)
private var matrix:Matrix = new Matrix();
private var transform:ColorTransform;
private var noiseRange:ColorTransform;
private var displacementFilter:DisplacementMapFilter;
private var displacementBitmap:BitmapData;
private var baseColor:uint;
private var currentBase:uint;
private var timer:Number = 0;
private var lights:FlxGroup;
private var weather:Weather;
private var weatherChanged:Number = -1;
public function Water(x:int,y:int,width:int,height:int,lights:FlxGroup,weather:Weather,baseColor:uint=0xFF686C53,reflectivity:Number=0.3)
{
// Set height/width/x/y
this.x = x;
this.y = y;
moves = false;
scrollFactor.x = 0;
transform = new ColorTransform(1,1,1,reflectivity);
rect = new Rectangle(0,0,width,height);
displacementBitmap = new BitmapData(width, height, false, 0);
makeGraphic(width,height,baseColor);
this.lights = lights;
this.weather = weather;
this.baseColor = baseColor;
// This is the filter that makes the reflection ripple
displacementFilter = new DisplacementMapFilter(displacementBitmap, zeroPoint, 1, 2, 256, 256, DisplacementMapFilterMode.COLOR, baseColor, 0.5);
// Reduce the range of perlin transform
}
override public function update():void
{
timer += FlxG.elapsed;
if (weather.changed > weatherChanged){
currentBase = 0xFF000000 | Utils.interpolateColor(baseColor, weather.darknessColor, weather.darkness)
var rippleScale:int = int(weather.wind*WIND_RIPPLE_MULTIPLIER);
var xscale:int = rippleScale/2;
var yscale:int = rippleScale;
noiseRange = new ColorTransform(xscale/128,yscale/128,1,1,(128-xscale+(NOISE_BIAS*xscale/128)),(128-yscale+(NOISE_BIAS*yscale/128)),1,1)
weatherChanged = weather.t
}
}
override public function draw():void
{
if (timer > 0.1)
{ // Update the water ripple
perlinOffset.y += 1/5;
perlinOffset.x = FlxG.camera.scroll.x*1.5;
displacementBitmap.perlinNoise(32, 4, 1, 12312, false, false, 1|2, true, [perlinOffset]);
displacementBitmap.colorTransform(rect,noiseRange);
// Adjust the base color according to the weather.
displacementFilter.color = currentBase;
timer = 0;
}
var px:BitmapData = pixels;
matrix.identity();
matrix.scale(1, -1);
getScreenXY(_point);
matrix.translate(-_point.x, _point.y);
// Clear the reflection
px.fillRect(rect, currentBase);
Utils.gradientOverlay(px, [0x00000000,0x66000000], 90, 4);
// Flip the screen and copy it to the reflection
px.draw(FlxG.camera.buffer, matrix, transform);
// Draw the lights
var l:Light;
for (var i:int = 0; i < lights.length; i++){
l = lights.members[i] as Light;
l.getScreenXY(_point);
if(l.visible && -64 < _point.x && _point.x < FlxG.width + 64){
l.reflected.alpha = weather.darkness * 0.8;
l.reflected.alpha *= Math.min(1.0, (weather.wind * 10));
l.reflected.drawFrame();
stamp(l.reflected, _point.x - l.reflected.width/2 + 4, (y - l.y) * 0.3);
}
}
// Apply the ripple filter
px.applyFilter(px, rect, zeroPoint, displacementFilter);
dirty = true;
super.draw()
}
}
}
================================================
FILE: Weather.as
================================================
package{
import org.flixel.FlxG;
import com.quasimondo.geom.ColorMatrix
public class Weather extends Object{
public var sky:uint = 0xFF8C8CA6;
public var horizon:uint = 0xFFCF7968;
public var haze:uint = 0xAAf3f1e8;
public var darknessColor:uint = 0x88111114;
public var darkness:Number = 1.0;
public var contrast:Number = 0.3;
public var saturation:Number = 1.0
public var ambient:uint = 0x11FF0000;
public var wind:Number = 0.0;
public var fog:Number = 0.5;
public var rain:Number = 0.5;
public var timeOfDay:Number = 0.5;
public var sunTint:uint = 0xFFFFFF;
public var ambientTransform:ColorMatrix = new ColorMatrix();
public var t:Number = 0;
public var changed:Number = 0;
public var progress:Number = 0;
public var ambientAmount:Number = 0;
public var tweenStart:Number = 0;
public var tweenDuration:Number = 0.0;
public var previousState:Object = WeatherPresets.SUNNY;
public var targetState:Object = WeatherPresets.SUNNY;
public function Weather(){
setVariables(WeatherPresets.SUNNY);
}
public function update():void{
t += FlxG.elapsed;
if (t - changed > 1/30){
updateTween();
changed = t;
}
}
public function tweenTo(state:Object, d:Number=30):void{
targetState = state;
if (d == 0){
setVariables(state)
previousState = state;
} else {
tweenDuration = d;
tweenStart = t;
}
}
public function updateTween():void{
if (targetState === previousState) return;
// Compute the tween factor
progress = (t - tweenStart)/tweenDuration;
if (tweenDuration == 0 || progress >= 1) {
previousState = targetState;
progress = 1;
}
setVariables(targetState, previousState, progress);
}
private function setVariables(target:Object, previous:Object=null, f:Number = 1):void{
// Very ugly
if (!target.hasOwnProperty('ambientAmount')){
target['ambientAmount'] = ((target['ambient'] >> 24) / 0xFF);
}
if (previous === null){
previous = target;
}
var fi:Number = 1 - f;
// Loop through the variables and tween them
for (var v:String in target){
// List non-color props here.
if (v == 'darkness' || v == 'contrast' || v == 'saturation' || v == 'fog' || v == 'rain' || v == 'wind' || v == 'ambientAmount'){
this[v] = (fi * previous[v]) + (f * target[v]);
// timeOfDay is weird and circular.
} else if (v == 'timeOfDay'){
if (target[v] > previous[v])
this[v] = (previous[v] + (target[v]-previous[v])*f)%1;
else
this[v] = (previous[v] + (target[v]+1-previous[v])*f)%1;
} else {
// Interpolate a color.
this[v] = Utils.interpolateColor(previous[v], target[v], f);
}
}
// Set the other vars
ambientTransform.reset();
ambientTransform.colorize(ambient, ambientAmount);
ambientTransform.adjustContrast(contrast);
ambientTransform.adjustSaturation(saturation);
// Set opacity of the darknessColor to darkness.
darknessColor = (darknessColor&0x00FFFFFF) | (uint(0xFF*darkness) << 24) ;
}
}
}
================================================
FILE: WeatherPresets.as
================================================
// THIS FILE IS AUTOGENERATED, MODIFY weathers.json IN STEAD.
package {
public class WeatherPresets extends Object{
public static const NIGHTGREEN:Object = {
'saturation': 0.7,
'darkness': 0.45,
'sky': 0xFF005EA5,
'haze': 0xFFB8F2BB,
'sunTint': 0xDDDDFF,
'fog': 0.4,
'contrast': 0.0,
'horizon': 0xFF002E80,
'ambient': 0x2254FFAF,
'timeOfDay': 0.85,
'wind': 0.1,
'darknessColor': 0x88263529
}
public static const NIGHTFOGGY:Object = {
'saturation': 0.7,
'darkness': 0.7,
'sky': 0xFF25229d,
'haze': 0xFFd5d9ff,
'sunTint': 0xffd9c8,
'fog': 1.0,
'contrast': -0.1,
'horizon': 0xFF6a6d55,
'ambient': 0x7763709d,
'timeOfDay': 0.8,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const NIGHTLONG:Object = {
'saturation': 1.0,
'darkness': 0.4,
'sky': 0xFF7399c8,
'sunTint': 0x162039,
'haze': 0xFF000000,
'fog': 0.0,
'wind': 0.1,
'horizon': 0xFF7399c8,
'ambient': 0x55acc857,
'timeOfDay': 0.9,
'contrast': 0.3,
'darknessColor': 0x88000000
}
public static const DAYCLEARCOLD:Object = {
'saturation': 0.7,
'darkness': 0.0,
'sky': 0xFFC9E3EA,
'haze': 0x33C9E3EA,
'sunTint': 0xF7E9AA,
'fog': 0.0,
'contrast': 0.2,
'horizon': 0xFFC9E3EA,
'ambient': 0x33F7E0C3,
'timeOfDay': 0.45,
'wind': 0.5,
'darknessColor': 0x88111114
}
public static const DAWNBLEAK:Object = {
'saturation': 0.9,
'darkness': 0.2,
'sky': 0xFFC4AD99,
'haze': 0xAAf3f1e8,
'sunTint': 0xF9B340,
'fog': 0.5,
'contrast': 0.5,
'horizon': 0xFFCECECE,
'ambient': 0x22FF84DA,
'timeOfDay': 0.31,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const DAYORANGESKY:Object = {
'saturation': 0.7,
'darkness': 0.1,
'sky': 0xFFADA290,
'haze': 0x445A432C,
'sunTint': 0xF9F8E6,
'fog': 0.3,
'contrast': 0.2,
'horizon': 0xFFDCAB4F,
'ambient': 0x110E0B22,
'timeOfDay': 0.4,
'wind': 0.7,
'darknessColor': 0x880E0B62
}
public static const DAYPASTEL:Object = {
'saturation': 1.0,
'darkness': 0.0,
'sky': 0xFF3090F6,
'sunTint': 0xF9F8E6,
'haze': 0xDD657A8F,
'fog': 0.0,
'wind': 0.3,
'horizon': 0xFFEEEE88,
'ambient': 0x44886A00,
'timeOfDay': 0.55,
'contrast': 1.0,
'darknessColor': 0x88000BBB
}
public static const DUSKPINK:Object = {
'saturation': 0.9,
'darkness': 0.0,
'sky': 0xFF8C8CA6,
'haze': 0xAAf3c1e8,
'sunTint': 0xF9B340,
'fog': 0.0,
'contrast': 0.8,
'horizon': 0xFFEDC99A,
'ambient': 0x44F79A42,
'timeOfDay': 0.651,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const DAWNCLEARORANGE:Object = {
'saturation': 0.8,
'darkness': 0.2,
'sky': 0xFF97A7B4,
'haze': 0x88FDB24C,
'sunTint': 0xFAFDC9,
'fog': 0.0,
'contrast': 0.5,
'horizon': 0xFFF9A04F,
'ambient': 0x11FF0000,
'timeOfDay': 0.28,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const EVENINGORANGE:Object = {
'saturation': 0.8,
'darkness': 0.1,
'sky': 0xFF8BB8E8,
'haze': 0xFFFF9068,
'sunTint': 0xFFFF7038,
'fog': 0.0,
'contrast': 0.7,
'horizon': 0xFFEDC99A,
'ambient': 0x33DE5E37,
'timeOfDay': 0.70,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const NIGHTSHINE:Object = {
'saturation': 0.5,
'darkness': 0.35,
'sky': 0xFF000000,
'sunTint': 0xF9F8E6,
'haze': 0x00886AAA,
'fog': 0.0,
'wind': 0.2,
'horizon': 0xFFAAAAFF,
'ambient': 0x00000000,
'timeOfDay': 0.9,
'contrast': 4.0,
'darknessColor': 0x88222255
}
public static const EVENINGFOGGY:Object = {
'saturation': 0.7,
'darkness': 0.3,
'sky': 0xFFd56c47,
'haze': 0xFFd5d9ff,
'sunTint': 0xffd9c8,
'fog': 1.0,
'contrast': -0.1,
'horizon': 0xFF6a6d55,
'ambient': 0x440000FF,
'timeOfDay': 0.7,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const NIGHTPURPLE:Object = {
'saturation': 0.8,
'darkness': 0.3,
'sky': 0xFF57577D,
'sunTint': 0xF9F8E6,
'haze': 0x88886AAA,
'fog': 0.0,
'wind': 0.2,
'horizon': 0xFF4D4658,
'ambient': 0x33886AAA,
'timeOfDay': 0.9,
'contrast': 1.4,
'darknessColor': 0x88990BBB
}
public static const EVENINGBLACK:Object = {
'saturation': 0.7,
'darkness': 0.3,
'sky': 0xFF333333,
'haze': 0xFFFF9090,
'sunTint': 0xFFFF7038,
'fog': 0.0,
'contrast': 0.0,
'horizon': 0xFFEDC99A,
'ambient': 0x339f6b5c,
'timeOfDay': 0.70,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const EVENINGMONOTONE:Object = {
'saturation': 0.7,
'darkness': 0.3,
'sky': 0xFF333333,
'haze': 0xFFFF9090,
'sunTint': 0xAAAAAA,
'fog': 0.0,
'contrast': 0.0,
'horizon': 0xFFEDEDED,
'ambient': 0x33666666,
'timeOfDay': 0.70,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const NIGHTCLEAR:Object = {
'saturation': 0.8,
'darkness': 0.4,
'sky': 0xFF005EA5,
'haze': 0x44434e87,
'sunTint': 0xDDDDFF,
'fog': 0.1,
'contrast': -0.1,
'horizon': 0xFF002E80,
'ambient': 0x110000FF,
'timeOfDay': 0.1,
'wind': 0.3,
'darknessColor': 0x88111114
}
public static const SUNNY:Object = {
'saturation': 0.8,
'darkness': 0.0,
'sky': 0xFF98BEEC,
'haze': 0xCCf3f1e8,
'sunTint': 0xfff766,
'fog': 0.0,
'contrast': 0.8,
'horizon': 0xFFC4DAF1,
'ambient': 0x44FFBB7F,
'timeOfDay': 0.6,
'wind': 1.0,
'darknessColor': 0x88111114
}
public static const DAYBLEAK:Object = {
'saturation': 0.7,
'darkness': 0.0,
'sky': 0xFFA0C2E8,
'haze': 0xFFf3f1e8,
'sunTint': 0xF7E9AA,
'fog': 1.0,
'contrast': 0.0,
'horizon': 0xFFA6C9ED,
'ambient': 0x33F7E0C3,
'timeOfDay': 0.45,
'wind': 0.5,
'darknessColor': 0x88111114
}
public static const NIGHTREDMOON:Object = {
'saturation': 0.9,
'darkness': 0.4,
'sky': 0xFF142744,
'haze': 0x665C5D9E,
'sunTint': 0xC73800,
'fog': 0.1,
'contrast': 0.2,
'horizon': 0xFFAD2E21,
'ambient': 0x220E0B62,
'timeOfDay': 0.1,
'wind': 0.1,
'darknessColor': 0x880E0B62
}
public static const DAYTEMP:Object = {
'saturation': 0.0,
'darkness': 0.2,
'sky': 0xFF6a6d55,
'haze': 0xFF999d7c,
'sunTint': 0xffffff,
'fog': 1.0,
'contrast': -0.2,
'horizon': 0xFF6a6d55,
'ambient': 0xFFFF0000,
'timeOfDay': 0.5,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const FOGGY:Object = {
'saturation': 0.7,
'darkness': 0.2,
'sky': 0xFF6a6d55,
'haze': 0xFF999d7c,
'sunTint': 0xffffff,
'fog': 1.0,
'contrast': -0.2,
'horizon': 0xFF6a6d55,
'ambient': 0x330000FF,
'timeOfDay': 0.25,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const DAWNBROWN:Object = {
'saturation': 0.8,
'darkness': 0.0,
'sky': 0xFFC0AFBD,
'sunTint': 0xF9F8E6,
'haze': 0x99AAAAAA,
'fog': 0.2,
'wind': 0.2,
'horizon': 0xFF94A9B6,
'ambient': 0x55AD3200,
'timeOfDay': 0.28,
'contrast': 0.7,
'darknessColor': 0x88222255
}
public static const DUSKFOGGY:Object = {
'saturation': 0.6,
'darkness': 0.25,
'sky': 0xFFB29C8F,
'sunTint': 0xF9F8E6,
'haze': 0x00000000,
'fog': 0.8,
'wind': 0.4,
'horizon': 0xFF3D6BCD,
'ambient': 0x330E0B22,
'timeOfDay': 0.75,
'contrast': 0.1,
'darknessColor': 0x880E0B62
}
public static const DAWNLIGHTPINK:Object = {
'saturation': 0.8,
'darkness': 0.1,
'sky': 0xFF8C8CA6,
'haze': 0xAAf3f1e8,
'sunTint': 0xF9B340,
'fog': 0.5,
'contrast': 0.5,
'horizon': 0xFFCF7968,
'ambient': 0x22FF84DA,
'timeOfDay': 0.28,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const NIGHTDARK:Object = {
'saturation': 0.7,
'darkness': 0.75,
'sky': 0xFF002E33,
'haze': 0xFF555555,
'sunTint': 0x65a2cb,
'fog': 0.0,
'contrast': 0.4,
'horizon': 0xFF002E80,
'ambient': 0x4454AACF,
'timeOfDay': 0.85,
'wind': 0.1,
'darknessColor': 0xFF263529
}
public static const DUSKWARM:Object = {
'saturation': 0.9,
'darkness': 0.0,
'sky': 0xFF8BB8E8,
'haze': 0x88f3f1e8,
'sunTint': 0xF4EED0,
'fog': 0.0,
'contrast': 0.8,
'horizon': 0xFFEDC99A,
'ambient': 0x44F79A42,
'timeOfDay': 0.651,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const DAWNEARLY:Object = {
'saturation': 0.9,
'darkness': 0.2,
'sky': 0xFFC4AD99,
'haze': 0xAAf3f1e8,
'sunTint': 0xF9B340,
'fog': 0.5,
'contrast': 0.5,
'horizon': 0xFFCECECE,
'ambient': 0x22FF84DA,
'timeOfDay': 0.19,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const DAWNBRIGHT:Object = {
'saturation': 0.8,
'darkness': 0.15,
'sky': 0xFF57577D,
'sunTint': 0xF9F8E6,
'haze': 0x00886AAA,
'fog': 0.0,
'wind': 0.2,
'horizon': 0xFFEEEE88,
'ambient': 0xff886A00,
'timeOfDay': 0.3,
'contrast': 1.4,
'darknessColor': 0x88000BBB
}
public static const DAWNGREY:Object = {
'saturation': 0.5,
'darkness': 0.2,
'sky': 0xFFC4AD99,
'haze': 0xAAf3f1e8,
'sunTint': 0xF9B340,
'fog': 0.5,
'contrast': 0.5,
'horizon': 0xFFCECECE,
'ambient': 0x22FF84DA,
'timeOfDay': 0.31,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const NIGHTSUPERDARK:Object = {
'saturation': 0.7,
'darkness': 0.7,
'sky': 0xFF000000,
'haze': 0xFFFFFFFF,
'sunTint': 0x65a2cb,
'fog': 0.0,
'contrast': 0.4,
'horizon': 0xFF002E80,
'ambient': 0x4454AACF,
'timeOfDay': 0.85,
'wind': 0.1,
'darknessColor': 0xFF263529
}
public static const DUSKCLEAR:Object = {
'saturation': 0.9,
'darkness': 0.2,
'sky': 0xFF513744,
'haze': 0xAAC9976D,
'sunTint': 0xF9B340,
'fog': 0.0,
'contrast': 0.45,
'horizon': 0xFFC69875,
'ambient': 0x22360A00,
'timeOfDay': 0.651,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const NIGHT:Object = {
'saturation': 0.8,
'darkness': 0.4,
'sky': 0xFF005EA5,
'haze': 0xFF333333,
'sunTint': 0xDDDDFF,
'fog': 0.2,
'contrast': 0.5,
'horizon': 0xFF002E80,
'ambient': 0x110000FF,
'timeOfDay': 0,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const DAWNTEMP:Object = {
'saturation': 0.0,
'darkness': 0.2,
'sky': 0xFF6a6d55,
'haze': 0xFF999d7c,
'sunTint': 0xffffff,
'fog': 1.0,
'contrast': -0.2,
'horizon': 0xFF6a6d55,
'ambient': 0xFFFF0000,
'timeOfDay': 0.25,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const DAYWINDYCLEAR:Object = {
'saturation': 1.0,
'darkness': 0.0,
'sky': 0xFF64A3EA,
'haze': 0x22f3f1e8,
'sunTint': 0xF7E9AA,
'fog': 0.0,
'contrast': 1.0,
'horizon': 0xFF86BAEF,
'ambient': 0x33F99100,
'timeOfDay': 0.45,
'wind': 0.5,
'darknessColor': 0x88111114
}
public static const DAWN:Object = {
'saturation': 0.8,
'darkness': 0.2,
'sky': 0xFF8C8CA6,
'haze': 0x66f3f1e8,
'sunTint': 0xff6d40,
'fog': 0.0,
'contrast': 0.5,
'horizon': 0xFFCF7968,
'ambient': 0x11FF0000,
'timeOfDay': 0.28,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const DAYSOFT:Object = {
'saturation': 0.7,
'darkness': 0.0,
'sky': 0xFFA0C2E8,
'haze': 0x22f3f1e8,
'sunTint': 0xF7E9AA,
'fog': 0.0,
'contrast': 0.0,
'horizon': 0xFFA6C9ED,
'ambient': 0x33F7E0C3,
'timeOfDay': 0.45,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const EVENING:Object = {
'saturation': 0.8,
'darkness': 0.1,
'sky': 0xFFFF7F51,
'haze': 0x99FF9068,
'sunTint': 0xFFFF7038,
'fog': 0.0,
'contrast': 0.7,
'horizon': 0xFFFFDF54,
'ambient': 0x33DE5E37,
'timeOfDay': 0.70,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const DAYMONOCHROME:Object = {
'saturation': 0.25,
'darkness': 0.0,
'sky': 0xFF80A2C8,
'haze': 0xFFf3f1e8,
'sunTint': 0xF7E9AA,
'fog': 1.0,
'contrast': 0.4,
'horizon': 0xFFA6C9ED,
'ambient': 0x33F7E0C3,
'timeOfDay': 0.45,
'wind': 0.5,
'darknessColor': 0x88111114
}
public static const DAWNREDMOON:Object = {
'saturation': 0.9,
'darkness': 0.2,
'sky': 0xFF16549F,
'haze': 0xbb5C5D9E,
'sunTint': 0xE76833,
'fog': 0.1,
'contrast': 0.0,
'horizon': 0xFFFF9286,
'ambient': 0x110E0B22,
'timeOfDay': 0.2,
'wind': 0.1,
'darknessColor': 0x880E0B62
}
public static const DUSKTAN:Object = {
'saturation': 0.8,
'darkness': 0.1,
'sky': 0xFF52424C,
'sunTint': 0xF9F8E6,
'haze': 0x55C18F90,
'fog': 0.0,
'wind': 0.3,
'horizon': 0xFFFFBA3B,
'ambient': 0xFF886A00,
'timeOfDay': 0.7,
'contrast': 0.5,
'darknessColor': 0x88330B33
}
public static const DUSKTEMP:Object = {
'saturation': 0.0,
'darkness': 0.2,
'sky': 0xFF6a6d55,
'haze': 0xFF999d7c,
'sunTint': 0xffffff,
'fog': 1.0,
'contrast': -0.2,
'horizon': 0xFF6a6d55,
'ambient': 0xFFFF0000,
'timeOfDay': 0.75,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const DUSKYELLOW:Object = {
'saturation': 0.9,
'darkness': 0.0,
'sky': 0xFF8BB8E8,
'haze': 0x88f3f1e8,
'sunTint': 0xF4EED0,
'fog': 0.0,
'contrast': 0.8,
'horizon': 0xFFEDC99A,
'ambient': 0x44F79A42,
'timeOfDay': 0.651,
'wind': 0.1,
'darknessColor': 0x88111114
}
public static const NIGHTTEMP:Object = {
'saturation': 0.0,
'darkness': 0.2,
'sky': 0xFF6a6d55,
'haze': 0xFF999d7c,
'sunTint': 0xffffff,
'fog': 1.0,
'contrast': -0.2,
'horizon': 0xFF6a6d55,
'ambient': 0xFFFF0000,
'timeOfDay': 0.0,
'wind': 0.2,
'darknessColor': 0x88111114
}
public static const DAYDUSTY:Object = {
'saturation': 0.8,
'darkness': 0.0,
'sky': 0xFF5d9df5,
'sunTint': 0xF9F8E6,
'haze': 0x99AAAAAA,
'fog': 0.2,
'wind': 0.2,
'horizon': 0xFF94A9B6,
'ambient': 0x55f5db04,
'timeOfDay': 0.4,
'contrast': 0.2,
'darknessColor': 0x88222255
}
public static const DUSKRED:Object = {
'saturation': 0.8,
'darkness': 0.2,
'sky': 0xFFd06219,
'sunTint': 0xf27612,
'haze': 0x99AAAAAA,
'fog': 0.2,
'wind': 0.2,
'horizon': 0xFFf2d407,
'ambient': 0x55f5db04,
'timeOfDay': 0.651,
'contrast': 0.1,
'darknessColor': 0x88000000
}
}
}
================================================
FILE: Workable.as
================================================
package
{
public interface Workable
{
function needsWork():Boolean;
function work(citizen:Citizen=null):void;
}
}
================================================
FILE: assets/levels/compiled/fields.oel
================================================
<?xml version="1.0" ?><level backdropCloseImg="SkylineTreesImg" backdropFarImg="SkylineHillsImg" waterHeight="152">
<width>3840</width>
<height>192</height>
<backdrop>
<Reed x="164" y="128"/>
<Reed x="196" y="128"/>
<Reed x="228" y="128"/>
<Reed x="324" y="128"/>
<Reed x="356" y="128"/>
<Reed x="388" y="128"/>
<Reed x="420" y="128"/>
<Reed x="528" y="112"/>
<Reed x="560" y="112"/>
<Reed x="592" y="112"/>
<Reed x="656" y="112"/>
<Reed x="688" y="112"/>
<Reed x="832" y="112"/>
<Reed x="864" y="112"/>
<Reed x="896" y="112"/>
<Reed x="1880" y="124"/>
<Reed x="1912" y="124"/>
<Reed x="1944" y="124"/>
<Reed x="1624" y="124"/>
<Reed x="2008" y="124"/>
<Reed x="2040" y="124"/>
<Reed x="1136" y="112"/>
<Reed x="1208" y="112"/>
<Reed x="260" y="128"/>
<Reed x="292" y="128"/>
<Reed x="1976" y="124"/>
<Reed x="2072" y="124"/>
<Hill x="800" y="128"/>
<Hill x="608" y="128"/>
<Hill x="508" y="128"/>
<Reed x="1168" y="112"/>
<Hill x="1104" y="128"/>
<Reed x="132" y="128"/>
<Reed x="100" y="128"/>
<Reed x="68" y="128"/>
<Reed x="36" y="128"/>
<Reed x="4" y="128"/>
<Reed x="1656" y="124"/>
<Reed x="1688" y="124"/>
<Reed x="1720" y="124"/>
<Reed x="1784" y="124"/>
<Reed x="1816" y="124"/>
<Reed x="1752" y="124"/>
<Reed x="1848" y="124"/>
</backdrop>
<ground set="tiles" tileHeight="32" tileWidth="32">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,10,18,1,5,4,3,4,5,2,4,3,4,5,6,14,16,15,15,16,15,17,9,10,8,10,9,8,8,10,9,10,10,9,8,9,11,12,13,14,15,17,10,8,9,10,9,8,10,10,9,11,15,12,16,15,12,12,15,12,15,12,16,15,17,10,10,9,10,8,9,8,9,9,11,12,13,14,16,17,9,10,9,9,10,9,10,8,9,10,9,8,10,10,11,15,16,15,12,15,13,1,3,4,2,6,4,5,2,3,4,5,6,7,8,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
</ground>
<objects>
<Castle x="1852" y="36"/>
<Shop x="1720" y="68"/>
<Shop x="2044" y="68"/>
</objects>
<farmlands>
<Farmland x="1488" y="104"/>
<Farmland x="2152" y="104"/>
<Farmland x="1064" y="104"/>
<Farmland x="1152" y="104"/>
<Farmland x="2300" y="104"/>
<Farmland x="2604" y="104"/>
<Farmland x="1584" y="104"/>
<Farmland x="2368" y="104"/>
</farmlands>
<walls>
<Wall x="1436" y="80"/>
<Wall x="2232" y="80"/>
<Wall x="2688" y="80"/>
<Wall x="996" y="80"/>
<Wall x="1812" y="80"/>
<Wall x="1996" y="80"/>
</walls>
<props>
<Treeline x="3744" y="0"/>
<Treeline x="0" y="0"/>
</props>
<lights>
<Torch x="1292" y="100"/>
<Torch x="1468" y="100"/>
<Torch x="1656" y="100"/>
<Torch x="2136" y="100"/>
<Torch x="2280" y="100"/>
<Torch x="2436" y="100"/>
<Torch x="1132" y="100"/>
<Torch x="1040" y="100"/>
<Firefly x="348" y="144"/>
<Firefly x="412" y="136"/>
<Firefly x="292" y="116"/>
<Firefly x="444" y="124"/>
<Firefly x="624" y="112"/>
<Firefly x="692" y="112"/>
<Firefly x="640" y="120"/>
<Firefly x="568" y="120"/>
<Firefly x="1232" y="120"/>
<Firefly x="1200" y="112"/>
<Firefly x="1268" y="136"/>
<Firefly x="1140" y="136"/>
<Firefly x="2576" y="140"/>
<Firefly x="2624" y="120"/>
<Firefly x="2680" y="136"/>
<Firefly x="3176" y="136"/>
<Firefly x="3132" y="128"/>
<Firefly x="3588" y="120"/>
<Firefly x="3524" y="140"/>
<Firefly x="3452" y="120"/>
<Firefly x="3392" y="136"/>
<Firefly x="3632" y="144"/>
<Torch x="1564" y="100"/>
<Torch x="2216" y="100"/>
<Torch x="2596" y="100"/>
<Torch x="2672" y="100"/>
</lights>
</level>
================================================
FILE: assets/levels/compiled/fields_alt.oel
================================================
<?xml version="1.0" ?><level backdropCloseImg="SkylineTreesImg" backdropFarImg="SkylineHillsImg" waterHeight="152">
<width>3840</width>
<height>192</height>
<backdrop>
<Reed x="164" y="128"/>
<Reed x="196" y="128"/>
<Reed x="228" y="128"/>
<Reed x="324" y="128"/>
<Reed x="356" y="128"/>
<Reed x="388" y="128"/>
<Reed x="420" y="128"/>
<Reed x="528" y="112"/>
<Reed x="560" y="112"/>
<Reed x="592" y="112"/>
<Reed x="656" y="112"/>
<Reed x="688" y="112"/>
<Reed x="832" y="112"/>
<Reed x="864" y="112"/>
<Reed x="896" y="112"/>
<Reed x="1880" y="124"/>
<Reed x="1912" y="124"/>
<Reed x="1944" y="124"/>
<Reed x="1624" y="124"/>
<Reed x="2008" y="124"/>
<Reed x="2040" y="124"/>
<Reed x="1136" y="112"/>
<Reed x="1208" y="112"/>
<Reed x="260" y="128"/>
<Reed x="292" y="128"/>
<Reed x="1976" y="124"/>
<Reed x="2072" y="124"/>
<Hill x="800" y="128"/>
<Hill x="608" y="128"/>
<Hill x="508" y="128"/>
<Reed x="1168" y="112"/>
<Hill x="1104" y="128"/>
<Reed x="132" y="128"/>
<Reed x="100" y="128"/>
<Reed x="68" y="128"/>
<Reed x="36" y="128"/>
<Reed x="4" y="128"/>
<Reed x="1656" y="124"/>
<Reed x="1688" y="124"/>
<Reed x="1720" y="124"/>
<Reed x="1784" y="124"/>
<Reed x="1816" y="124"/>
<Reed x="1752" y="124"/>
<Reed x="1848" y="124"/>
</backdrop>
<ground set="tiles" tileHeight="32" tileWidth="32">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,10,18,1,5,4,3,4,5,2,4,3,4,5,6,14,16,15,15,16,15,17,9,10,8,10,9,8,8,10,9,10,10,9,8,9,11,12,13,14,15,17,10,8,9,10,9,8,10,10,9,9,8,11,16,15,12,12,15,12,15,12,16,15,17,10,10,9,10,8,9,8,9,9,11,12,13,14,16,17,9,10,9,9,10,9,10,8,9,10,9,8,10,10,11,15,16,15,12,15,13,1,3,4,2,6,4,5,2,3,4,5,6,7,8,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
</ground>
<objects>
<Castle x="1852" y="36"/>
<Shop x="1768" y="68"/>
<Shop x="2044" y="68"/>
</objects>
<farmlands>
<Farmland x="1508" y="104"/>
<Farmland x="2260" y="104"/>
<Farmland x="936" y="104"/>
<Farmland x="1032" y="104"/>
<Farmland x="2712" y="104"/>
<Farmland x="2812" y="104"/>
<Torch x="2788" y="100"/>
<Torch x="3016" y="100"/>
<Farmland x="1700" y="104"/>
</farmlands>
<walls>
<Wall x="1420" y="80"/>
<Wall x="2388" y="80"/>
<Wall x="3044" y="80"/>
<Wall x="740" y="80"/>
<Wall x="1660" y="80"/>
<Wall x="1988" y="80"/>
</walls>
<props>
<Treeline x="3744" y="0"/>
<Treeline x="0" y="0"/>
</props>
<lights>
<Torch x="1292" y="100"/>
<Torch x="1472" y="100"/>
<Torch x="1636" y="100"/>
<Torch x="2136" y="100"/>
<Torch x="2352" y="100"/>
<Torch x="2548" y="100"/>
<Torch x="1008" y="100"/>
<Torch x="776" y="100"/>
<Firefly x="348" y="144"/>
<Firefly x="412" y="136"/>
<Firefly x="292" y="116"/>
<Firefly x="444" y="124"/>
<Firefly x="624" y="112"/>
<Firefly x="692" y="112"/>
<Firefly x="640" y="120"/>
<Firefly x="568" y="120"/>
<Firefly x="1232" y="120"/>
<Firefly x="1200" y="112"/>
<Firefly x="1268" y="136"/>
<Firefly x="1140" y="136"/>
<Firefly x="2572" y="140"/>
<Firefly x="2620" y="120"/>
<Firefly x="2676" y="136"/>
<Firefly x="3176" y="136"/>
<Firefly x="3132" y="128"/>
<Firefly x="3588" y="120"/>
<Firefly x="3524" y="140"/>
<Firefly x="3452" y="120"/>
<Firefly x="3392" y="136"/>
<Firefly x="3632" y="144"/>
</lights>
</level>
================================================
FILE: assets/levels/compiled/fields_loose.oel
================================================
<?xml version="1.0" ?><level backdropCloseImg="SkylineTreesImg" backdropFarImg="SkylineHillsImg" waterHeight="152">
<width>3840</width>
<height>192</height>
<backdrop>
<Reed x="164" y="128"/>
<Reed x="196" y="128"/>
<Reed x="228" y="128"/>
<Reed x="324" y="128"/>
<Reed x="356" y="128"/>
<Reed x="388" y="128"/>
<Reed x="420" y="128"/>
<Reed x="528" y="112"/>
<Reed x="560" y="112"/>
<Reed x="592" y="112"/>
<Reed x="656" y="112"/>
<Reed x="688" y="112"/>
<Reed x="832" y="112"/>
<Reed x="864" y="112"/>
<Reed x="896" y="112"/>
<Reed x="1880" y="124"/>
<Reed x="1912" y="124"/>
<Reed x="1944" y="124"/>
<Reed x="1624" y="124"/>
<Reed x="2008" y="124"/>
<Reed x="2040" y="124"/>
<Reed x="1136" y="112"/>
<Reed x="1208" y="112"/>
<Reed x="260" y="128"/>
<Reed x="292" y="128"/>
<Reed x="1976" y="124"/>
<Reed x="2072" y="124"/>
<Hill x="800" y="128"/>
<Hill x="608" y="128"/>
<Hill x="508" y="128"/>
<Reed x="1168" y="112"/>
<Hill x="1104" y="128"/>
<Reed x="132" y="128"/>
<Reed x="100" y="128"/>
<Reed x="68" y="128"/>
<Reed x="36" y="128"/>
<Reed x="4" y="128"/>
<Reed x="1656" y="124"/>
<Reed x="1688" y="124"/>
<Reed x="1720" y="124"/>
<Reed x="1784" y="124"/>
<Reed x="1816" y="124"/>
<Reed x="1752" y="124"/>
<Reed x="1848" y="124"/>
</backdrop>
<ground set="tiles" tileHeight="32" tileWidth="32">0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,10,18,1,5,4,3,4,5,2,4,3,4,5,6,14,16,15,15,16,15,17,9,10,8,10,9,8,8,10,9,10,10,9,8,9,11,12,13,14,15,17,10,8,9,10,9,8,10,10,9,11,15,12,16,15,12,12,15,12,15,12,16,15,17,10,10,9,10,8,9,8,9,9,11,12,13,14,16,17,9,10,9,9,10,9,10,8,9,10,9,8,10,10,11,15,16,15,12,15,13,1,3,4,2,6,4,5,2,3,4,5,6,7,8,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
</ground>
<objects>
<Castle x="1852" y="36"/>
<Shop x="1720" y="68"/>
<Shop x="2044" y="68"/>
</objects>
<farmlands>
<Farmland x="1464" y="104"/>
<Farmland x="2156" y="104"/>
<Farmland x="936" y="104"/>
<Farmland x="1032" y="104"/>
<Farmland x="2712" y="104"/>
<Farmland x="2812" y="104"/>
<Torch x="2788" y="100"/>
<Torch x="3016" y="100"/>
<Farmland x="1552" y="104"/>
</farmlands>
<walls>
<Wall x="1404" y="80"/>
<Wall x="2232" y="80"/>
<Wall x="3044" y="80"/>
<Wall x="740" y="80"/>
<Wall x="1812" y="80"/>
<Wall x="1988" y="80"/>
</walls>
<props>
<Treeline x="3744" y="0"/>
<Treeline x="0" y="0"/>
</props>
<lights>
<Torch x="1292" y="100"/>
<Torch x="1440" y="100"/>
<Torch x="1636" y="100"/>
<Torch x="2136" y="100"/>
<Torch x="2352" y="100"/>
<Torch x="2548" y="100"/>
<Torch x="1008" y="100"/>
<Torch x="776" y="100"/>
<Firefly x
gitextract_jv9k2wr7/ ├── .gitignore ├── Arrow.as ├── Attention.as ├── Buildable.as ├── Bunny.as ├── CameraTarget.as ├── Campfire.as ├── Castle.as ├── Citizen.as ├── Coin.as ├── CoinFloat.as ├── Coinsack.as ├── Default.css ├── Dust.as ├── ExplodingText.as ├── Farmland.as ├── Firefly.as ├── FlxBackdrop.as ├── FlxBaker.as ├── FlxBumpmap.as ├── FlxMatrixblock.as ├── Fog.as ├── GameOverState.as ├── Haze.as ├── LICENSE.txt ├── Light.as ├── Makefile ├── MenuState.as ├── Minimap.as ├── PlayState.as ├── Player.as ├── Preloader.as ├── Reed.as ├── Scaffold.as ├── Shop.as ├── Sky.as ├── Sparkle.as ├── Splash.as ├── SunMoon.as ├── Torch.as ├── Treeline.as ├── Troll.as ├── Utils.as ├── Wall.as ├── Water.as ├── Weather.as ├── WeatherPresets.as ├── Workable.as ├── assets/ │ ├── levels/ │ │ ├── compiled/ │ │ │ ├── fields.oel │ │ │ ├── fields_alt.oel │ │ │ ├── fields_loose.oel │ │ │ └── fields_old.oel │ │ ├── fields.oel │ │ ├── fields_alt.oel │ │ ├── fields_loose.oel │ │ ├── fields_old.oel │ │ └── ogmoconfig.oep │ └── sound/ │ ├── build.bfxrsound │ ├── cicada.aiff │ ├── hit.bfxrsound │ ├── hitbig.bfxrsound │ ├── hitcitizen.bfxrsound │ ├── hitwall.bfxrsound │ ├── pickup.bfxrsound │ ├── powerup.bfxrsound │ ├── stolen.bfxrsound │ └── throw.bfxrsound ├── com/ │ └── quasimondo/ │ └── geom/ │ └── ColorMatrix.as ├── convert_sounds.sh ├── convert_tiles.py ├── convert_weather.py ├── king.as ├── org/ │ └── flixel/ │ ├── FlxBasic.as │ ├── FlxButton.as │ ├── FlxCamera.as │ ├── FlxEmitter.as │ ├── FlxG.as │ ├── FlxGame.as │ ├── FlxGroup.as │ ├── FlxInputText.as │ ├── FlxObject.as │ ├── FlxParticle.as │ ├── FlxPath.as │ ├── FlxPoint.as │ ├── FlxRect.as │ ├── FlxSave.as │ ├── FlxSound.as │ ├── FlxSprite.as │ ├── FlxState.as │ ├── FlxText.as │ ├── FlxTileblock.as │ ├── FlxTilemap.as │ ├── FlxTimer.as │ ├── FlxU.as │ ├── plugin/ │ │ ├── DebugPathDisplay.as │ │ └── TimerManager.as │ └── system/ │ ├── FlxAnim.as │ ├── FlxDebugger.as │ ├── FlxList.as │ ├── FlxPreloader.as │ ├── FlxQuadTree.as │ ├── FlxReplay.as │ ├── FlxTile.as │ ├── FlxTilemapBuffer.as │ ├── FlxWindow.as │ ├── debug/ │ │ ├── Log.as │ │ ├── Perf.as │ │ ├── VCR.as │ │ ├── Vis.as │ │ ├── Watch.as │ │ └── WatchEntry.as │ ├── input/ │ │ ├── Input.as │ │ ├── Keyboard.as │ │ └── Mouse.as │ └── replay/ │ ├── FrameRecord.as │ └── MouseRecord.as ├── todo.txt └── weathers.json
SYMBOL INDEX (2 symbols across 1 files) FILE: convert_tiles.py function compile_levels (line 13) | def compile_levels(): function flatten_ogmo_tilemaps (line 32) | def flatten_ogmo_tilemaps(ogmo_path, ogmo_flattened_path):
Condensed preview — 118 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (812K chars).
[
{
"path": ".gitignore",
"chars": 38,
"preview": "*.swf\n.DS_Store\nMochiWrapper.as\nmochi/"
},
{
"path": "Arrow.as",
"chars": 1495,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxParticle;\n import org.flixel.FlxG;\n import or"
},
{
"path": "Attention.as",
"chars": 949,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxParticle;\n import org.flixel.FlxG;\n import or"
},
{
"path": "Buildable.as",
"chars": 134,
"preview": "package\n{ \n public interface Buildable\n {\n function canBuild():Boolean;\n \n function build()"
},
{
"path": "Bunny.as",
"chars": 2168,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "CameraTarget.as",
"chars": 2515,
"preview": "package{\n import org.flixel.FlxObject;\n import org.flixel.FlxPoint;\n import org.flixel.FlxSprite;\n \n /** "
},
{
"path": "Campfire.as",
"chars": 959,
"preview": "package{\n\n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n \n public class Campfire extends Light{\n "
},
{
"path": "Castle.as",
"chars": 4405,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxGroup;\n import "
},
{
"path": "Citizen.as",
"chars": 17871,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "Coin.as",
"chars": 2210,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxParticle;\n import org.flixel.FlxG;\n import or"
},
{
"path": "CoinFloat.as",
"chars": 832,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxG;\n import org.flixel.FlxObject;\n import org."
},
{
"path": "Coinsack.as",
"chars": 1256,
"preview": "package\n{\n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n \n public class Coinsack extends FlxSprite{"
},
{
"path": "Default.css",
"chars": 88,
"preview": "Add this: \"-defaults-css-url Default.css\"\nto the project's additonal compiler arguments."
},
{
"path": "Dust.as",
"chars": 863,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxParticle;\n import org.flixel.FlxG;\n import or"
},
{
"path": "ExplodingText.as",
"chars": 285,
"preview": "package\n{\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxGroup;\n import org.flixel.FlxG;\n import o"
},
{
"path": "Farmland.as",
"chars": 1394,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "Firefly.as",
"chars": 2214,
"preview": "package{\n\n import org.flixel.FlxSprite;\n import org.flixel.FlxPoint;\n import org.flixel.FlxG;\n \n public c"
},
{
"path": "FlxBackdrop.as",
"chars": 1692,
"preview": "package{\n import flash.geom.Point;\n import flash.display.BitmapData;\n \n import org.flixel.FlxSprite;\n imp"
},
{
"path": "FlxBaker.as",
"chars": 835,
"preview": "package{\n \n import flash.geom.Rectangle;\n import flash.geom.Point;\n import flash.display.BitmapData;\n imp"
},
{
"path": "FlxBumpmap.as",
"chars": 3017,
"preview": "package{\n import flash.display.BitmapData;\n import flash.filters.ConvolutionFilter;\n import flash.geom.Rectangl"
},
{
"path": "FlxMatrixblock.as",
"chars": 4283,
"preview": "package\n{\n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import flash.display.BitmapData;\n import f"
},
{
"path": "Fog.as",
"chars": 2522,
"preview": "package\n{\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxGroup;\n import org.flixel.FlxObject;\n imp"
},
{
"path": "GameOverState.as",
"chars": 1531,
"preview": "package\r\n{\r\n\timport org.flixel.*;\r\n\timport flash.ui.Mouse;\t\r\n import mochi.as3.MochiScores;\r\n\r\n\tpublic class GameOver"
},
{
"path": "Haze.as",
"chars": 790,
"preview": "package{\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n \n public class Haze extends FlxSprite{"
},
{
"path": "LICENSE.txt",
"chars": 1497,
"preview": "\nCopyright (c) 2013 Thomas \"noio\" van den Berg\n\nPermission is granted to any person obtaining a copy of this code and th"
},
{
"path": "Light.as",
"chars": 2248,
"preview": "package{\n\n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n \n public class Light extends FlxSprite{\n "
},
{
"path": "Makefile",
"chars": 1183,
"preview": "# term makefile\n#\n# files and directories\n#\n\nBINDIR = .\nSOURCE = ./king.as\nTARGET = $(BINDIR)/main.swf\n\n\n#\n# compiler "
},
{
"path": "MenuState.as",
"chars": 1877,
"preview": "package\r\n{\r\n\timport org.flixel.*;\r\n\r\n\tpublic class MenuState extends FlxState\r\n\t{\r\n [Embed(source='/assets/gfx/ti"
},
{
"path": "Minimap.as",
"chars": 1786,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "PlayState.as",
"chars": 46436,
"preview": "package\r\n{\r\n import org.flixel.*;\r\n import flash.geom.*;\r\n import flash.events.Event;\r\n import flash.utils.g"
},
{
"path": "Player.as",
"chars": 9988,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "Preloader.as",
"chars": 188,
"preview": "package\r\n{\r\n\timport org.flixel.system.FlxPreloader;\r\n\r\n\tpublic class Preloader extends FlxPreloader\r\n\t{\r\n\t\tpublic functi"
},
{
"path": "Reed.as",
"chars": 1168,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "Scaffold.as",
"chars": 688,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxGroup;\n import "
},
{
"path": "Shop.as",
"chars": 2267,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxGroup;\n import "
},
{
"path": "Sky.as",
"chars": 773,
"preview": "package{\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n \n public class Sky extends FlxSprite{\n"
},
{
"path": "Sparkle.as",
"chars": 718,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxParticle;\n import org.flixel.FlxG;\n import or"
},
{
"path": "Splash.as",
"chars": 691,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxParticle;\n import org.flixel.FlxG;\n import or"
},
{
"path": "SunMoon.as",
"chars": 1850,
"preview": "package{\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n \n public class SunMoon extends Light{\n"
},
{
"path": "Torch.as",
"chars": 1442,
"preview": "package{\n\n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n \n public class Torch extends Light{\n "
},
{
"path": "Treeline.as",
"chars": 545,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "Troll.as",
"chars": 8007,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "Utils.as",
"chars": 15567,
"preview": "package\n{\n import flash.display.BitmapData;\n import flash.display.Shape;\n import flash.geom.Rectangle;\n impo"
},
{
"path": "Wall.as",
"chars": 4646,
"preview": "package\n{\n import flash.geom.Point;\n \n import org.flixel.FlxSprite;\n import org.flixel.FlxG;\n import org."
},
{
"path": "Water.as",
"chars": 4841,
"preview": "package\n{\n import flash.display.BitmapData;\n import flash.display.BitmapDataChannel;\n import flash.filters.Disp"
},
{
"path": "Weather.as",
"chars": 3990,
"preview": "package{\n \n import org.flixel.FlxG;\n \n import com.quasimondo.geom.ColorMatrix\n \n public class Weather "
},
{
"path": "WeatherPresets.as",
"chars": 13652,
"preview": "// THIS FILE IS AUTOGENERATED, MODIFY weathers.json IN STEAD.\n\npackage {\npublic class WeatherPresets extends Object{\n\tpu"
},
{
"path": "Workable.as",
"chars": 153,
"preview": "package\n{ \n public interface Workable\n {\n function needsWork():Boolean;\n \n function work(ci"
},
{
"path": "assets/levels/compiled/fields.oel",
"chars": 4763,
"preview": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n <w"
},
{
"path": "assets/levels/compiled/fields_alt.oel",
"chars": 4666,
"preview": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n <w"
},
{
"path": "assets/levels/compiled/fields_loose.oel",
"chars": 4668,
"preview": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n <w"
},
{
"path": "assets/levels/compiled/fields_old.oel",
"chars": 4635,
"preview": "<?xml version=\"1.0\" ?><level backdropCloseImg=\"SkylineTreesImg\" backdropFarImg=\"SkylineHillsImg\" waterHeight=\"152\">\n <w"
},
{
"path": "assets/levels/fields.oel",
"chars": 7739,
"preview": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n <width>3840</width>\n <h"
},
{
"path": "assets/levels/fields_alt.oel",
"chars": 7642,
"preview": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n <width>3840</width>\n <h"
},
{
"path": "assets/levels/fields_loose.oel",
"chars": 7644,
"preview": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n <width>3840</width>\n <h"
},
{
"path": "assets/levels/fields_old.oel",
"chars": 7611,
"preview": "<level backdropFarImg=\"SkylineHillsImg\" backdropCloseImg=\"SkylineTreesImg\" waterHeight=\"152\">\n <width>3840</width>\n <h"
},
{
"path": "assets/levels/ogmoconfig.oep",
"chars": 2144,
"preview": "<project>\n <name>Kingdom</name>\n <settings>\n <defaultWidth>3840</defaultWidth>\n <defaultHeight>192</"
},
{
"path": "assets/sound/build.bfxrsound",
"chars": 86,
"preview": "2,0.5,,0.0781,0.3599,0.1093,0.3,0.413,,,,,,,,,0.125,0.6214,,,,,,,,1,,,,,,,masterVolume"
},
{
"path": "assets/sound/hit.bfxrsound",
"chars": 82,
"preview": "1,0.5,,0.0695,,0.1577,0.3,0.4565,,-0.515,,,,,,,,,,,,,,,,1,,,0.2087,,,,masterVolume"
},
{
"path": "assets/sound/hitbig.bfxrsound",
"chars": 123,
"preview": "1.0413,0.5,0.175,0.295,0.055,0.13,0.22,0.53,,-0.36,0.0402,,0.0232,,,0.0081,,,,0.0451,,,,,,1,-0.0025,,0.2087,,,,masterVol"
},
{
"path": "assets/sound/hitcitizen.bfxrsound",
"chars": 278,
"preview": "2,0.21,0.11,0.035,,0.265,0.185,0.155,,-0.2099,-0.0625,0.0402,,0.165,,0.0375,0.0148,0.0419,0.0449,,,-0.0012,0.0103,-0.067"
},
{
"path": "assets/sound/hitwall.bfxrsound",
"chars": 130,
"preview": "1,0.2,,0.0695,0.395,0.23,0.3,0.4565,,-0.395,,0.395,,0.12,0.415,,,,,,,,,0.2649,-0.145,0.35,-0.155,,0.2087,,0.25,-0.045,ma"
},
{
"path": "assets/sound/pickup.bfxrsound",
"chars": 82,
"preview": "2,0.5,,0.055,0.5256,0.2387,0.3,0.55,,,,,,,,,0.4,0.6179,,,,,,,,1,,,,,,,masterVolume"
},
{
"path": "assets/sound/powerup.bfxrsound",
"chars": 72,
"preview": "1,0.32,,0.195,,0.45,0.3,0.14,,0.1997,,,,,,,,,,,,,,,,1,,,,,,,masterVolume"
},
{
"path": "assets/sound/stolen.bfxrsound",
"chars": 105,
"preview": ",0.29,,0.515,0.165,0.25,0.3,0.13,,-0.175,,,,,,,,,,,0.1867,,,,0.195,1,,,0.1,0.2649,0.375,0.03,masterVolume"
},
{
"path": "assets/sound/throw.bfxrsound",
"chars": 85,
"preview": "2,0.5,0.12,0.065,0.165,0.165,0.3,0.45,,0.2299,0.03,,,,,,,,,,,,,,,1,,,,,,,masterVolume"
},
{
"path": "com/quasimondo/geom/ColorMatrix.as",
"chars": 29040,
"preview": "/*\n\n\tColorMatrix Class v2.41\n\n\treleased under MIT License (X11)\n\thttp://www.opensource.org/licenses/mit-license.php\n\n\tAu"
},
{
"path": "convert_sounds.sh",
"chars": 225,
"preview": "#! /bin/bash\nfor i in assets/sound/*.{wav,aiff}; \ndo echo \"converting $i ...\"; \nfilename=$(basename \"$i\")\nfilename=\"${fi"
},
{
"path": "convert_tiles.py",
"chars": 3147,
"preview": "#!/usr/bin/python\n\nimport os, sys\nfrom xml.dom import minidom\n\n#--------------------------------------\nBASE_PATH = os.pa"
},
{
"path": "convert_weather.py",
"chars": 1070,
"preview": "#! /usr/bin/env python\n\nimport json\nimport re\n\nWEATHER_RX = r'public static const ([A-Z_]*):Object = ({[^\\}]*})'\nPROP_RX"
},
{
"path": "king.as",
"chars": 347,
"preview": "package\r\n{\r\n\timport org.flixel.*;\r\n\t\r\n\t[SWF(width=\"864\", height=\"480\", backgroundColor=\"#000000\")]\r\n\t[Frame(factoryClass"
},
{
"path": "org/flixel/FlxBasic.as",
"chars": 4265,
"preview": "package org.flixel\n{\t\n\t/**\n\t * This is a useful \"generic\" Flixel object.\n\t * Both <code>FlxObject</code> and <code>FlxGr"
},
{
"path": "org/flixel/FlxButton.as",
"chars": 9318,
"preview": "package org.flixel\n{\n\timport flash.events.MouseEvent;\n\t\n\t/**\n\t * A simple button class that calls a function when clicke"
},
{
"path": "org/flixel/FlxCamera.as",
"chars": 20658,
"preview": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite;\n\timpo"
},
{
"path": "org/flixel/FlxEmitter.as",
"chars": 11101,
"preview": "package org.flixel\n{\n\n\t/**\n\t * <code>FlxEmitter</code> is a lightweight particle emitter.\n\t * It can be used for one-tim"
},
{
"path": "org/flixel/FlxG.as",
"chars": 40030,
"preview": "package org.flixel\n{\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\timport flash.display.Sprite;\n\tim"
},
{
"path": "org/flixel/FlxGame.as",
"chars": 22363,
"preview": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\tim"
},
{
"path": "org/flixel/FlxGroup.as",
"chars": 16044,
"preview": "package org.flixel\n{\n\t/**\n\t * This is an organizational class that can update and render a bunch of <code>FlxBasic</code"
},
{
"path": "org/flixel/FlxInputText.as",
"chars": 5731,
"preview": "package org.flixel\n{\n\timport flash.text.TextField;\n\timport org.flixel.*;\n\timport flash.events.Event;\n\timport flash.text."
},
{
"path": "org/flixel/FlxObject.as",
"chars": 40259,
"preview": "package org.flixel\n{\n\timport flash.display.Graphics;\n\timport flash.display.Sprite;\n\timport flash.geom.Point;\n\t\n\timport o"
},
{
"path": "org/flixel/FlxParticle.as",
"chars": 2338,
"preview": "package org.flixel\n{\n\t\n\t/**\n\t * This is a simple particle class that extends the default behavior\n\t * of <code>FlxSprite"
},
{
"path": "org/flixel/FlxPath.as",
"chars": 8537,
"preview": "package org.flixel\n{\n\timport flash.display.Graphics;\n\t\n\timport org.flixel.plugin.DebugPathDisplay;\n\t\n\t/**\n\t * This is a "
},
{
"path": "org/flixel/FlxPoint.as",
"chars": 2037,
"preview": "package org.flixel\n{\n\timport flash.geom.Point;\n\t\n\t/**\n\t * Stores a 2D floating point coordinate.\n\t * \n\t * @author\tAdam A"
},
{
"path": "org/flixel/FlxRect.as",
"chars": 3725,
"preview": "package org.flixel\n{\n\timport flash.geom.Rectangle;\n\n\t/**\n\t * Stores a rectangle.\n\t * \n\t * @author\tAdam Atomic\n\t */\n\tpubl"
},
{
"path": "org/flixel/FlxSave.as",
"chars": 5407,
"preview": "package org.flixel\n{\n\timport flash.events.NetStatusEvent;\n\timport flash.net.SharedObject;\n\timport flash.net.SharedObject"
},
{
"path": "org/flixel/FlxSound.as",
"chars": 13814,
"preview": "package org.flixel\n{\n\timport flash.events.Event;\n\timport flash.media.Sound;\n\timport flash.media.SoundChannel;\n\timport fl"
},
{
"path": "org/flixel/FlxSprite.as",
"chars": 28429,
"preview": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\tim"
},
{
"path": "org/flixel/FlxState.as",
"chars": 703,
"preview": "package org.flixel\n{\n\timport org.flixel.system.FlxQuadTree;\n\t\n\t/**\n\t * This is the basic game \"state\" object - e.g. in a"
},
{
"path": "org/flixel/FlxText.as",
"chars": 8621,
"preview": "package org.flixel\n{\n\timport flash.display.BitmapData;\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\t\n\t/"
},
{
"path": "org/flixel/FlxTileblock.as",
"chars": 2774,
"preview": "package org.flixel\n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Rectangle;\n\t\n\t/**\n\t * This is a basic \"environ"
},
{
"path": "org/flixel/FlxTilemap.as",
"chars": 46892,
"preview": "package org.flixel\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Graphics;\n\tim"
},
{
"path": "org/flixel/FlxTimer.as",
"chars": 3971,
"preview": "package org.flixel\n{\n\timport org.flixel.plugin.TimerManager;\n\t\n\t/**\n\t * A simple timer class, leveraging the new plugins"
},
{
"path": "org/flixel/FlxU.as",
"chars": 19944,
"preview": "package org.flixel\n{\n\timport flash.net.URLRequest;\n\timport flash.net.navigateToURL;\n\timport flash.utils.getDefinitionByN"
},
{
"path": "org/flixel/plugin/DebugPathDisplay.as",
"chars": 2628,
"preview": "package org.flixel.plugin\n{\n\timport org.flixel.*;\n\t\n\t/**\n\t * A simple manager for tracking and drawing FlxPath debug dat"
},
{
"path": "org/flixel/plugin/TimerManager.as",
"chars": 1943,
"preview": "package org.flixel.plugin\n{\n\timport org.flixel.*;\n\t\n\t/**\n\t * A simple manager for tracking and updating game timer objec"
},
{
"path": "org/flixel/system/FlxAnim.as",
"chars": 1218,
"preview": "package org.flixel.system\n{\n\t/**\n\t * Just a helper structure for the FlxSprite animation system.\n\t * \n\t * @author\tAdam A"
},
{
"path": "org/flixel/system/FlxDebugger.as",
"chars": 6116,
"preview": "package org.flixel.system\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite"
},
{
"path": "org/flixel/system/FlxList.as",
"chars": 791,
"preview": "package org.flixel.system\n{\n\timport org.flixel.FlxObject;\n\t\n\t/**\n\t * A miniature linked list class.\n\t * Useful for optim"
},
{
"path": "org/flixel/system/FlxPreloader.as",
"chars": 7958,
"preview": "package org.flixel.system\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Displa"
},
{
"path": "org/flixel/system/FlxQuadTree.as",
"chars": 18684,
"preview": "package org.flixel.system\n{\n\timport org.flixel.FlxBasic;\n\timport org.flixel.FlxGroup;\n\timport org.flixel.FlxObject;\n\timp"
},
{
"path": "org/flixel/system/FlxReplay.as",
"chars": 4742,
"preview": "package org.flixel.system\n{\n\timport org.flixel.FlxG;\n\timport org.flixel.system.replay.FrameRecord;\n\timport org.flixel.sy"
},
{
"path": "org/flixel/system/FlxTile.as",
"chars": 2754,
"preview": "package org.flixel.system\n{\n\timport org.flixel.FlxObject;\n\timport org.flixel.FlxTilemap;\n\t\n\t/**\n\t * A simple helper obje"
},
{
"path": "org/flixel/system/FlxTilemapBuffer.as",
"chars": 3149,
"preview": "package org.flixel.system\n{\n\timport flash.display.BitmapData;\n\timport flash.geom.Point;\n\timport flash.geom.Rectangle;\n\t\n"
},
{
"path": "org/flixel/system/FlxWindow.as",
"chars": 8146,
"preview": "package org.flixel.system\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display.Sprite"
},
{
"path": "org/flixel/system/debug/Log.as",
"chars": 2512,
"preview": "package org.flixel.system.debug\n{\n\timport flash.geom.Rectangle;\n\timport flash.text.TextField;\n\timport flash.text.TextFor"
},
{
"path": "org/flixel/system/debug/Perf.as",
"chars": 5651,
"preview": "package org.flixel.system.debug\n{\n\timport flash.geom.Rectangle;\n\timport flash.system.System;\n\timport flash.text.TextFiel"
},
{
"path": "org/flixel/system/debug/VCR.as",
"chars": 16728,
"preview": "package org.flixel.system.debug\n{\n\timport flash.display.Bitmap;\n\timport flash.display.BitmapData;\n\timport flash.display."
},
{
"path": "org/flixel/system/debug/Vis.as",
"chars": 4105,
"preview": "package org.flixel.system.debug\n{\n\timport flash.display.Bitmap;\n\timport flash.display.Sprite;\n\timport flash.events.Event"
},
{
"path": "org/flixel/system/debug/Watch.as",
"chars": 6178,
"preview": "package org.flixel.system.debug\n{\n\timport flash.display.Sprite;\n\timport flash.geom.Rectangle;\n\timport flash.text.TextFie"
},
{
"path": "org/flixel/system/debug/WatchEntry.as",
"chars": 5383,
"preview": "package org.flixel.system.debug\n{\n\timport flash.events.KeyboardEvent;\n\timport flash.events.MouseEvent;\n\timport flash.tex"
},
{
"path": "org/flixel/system/input/Input.as",
"chars": 4109,
"preview": "package org.flixel.system.input\n{\n\t/**\n\t * Basic input class that manages the fast-access Booleans and detailed key-stat"
},
{
"path": "org/flixel/system/input/Keyboard.as",
"chars": 5124,
"preview": "package org.flixel.system.input\n{\n\timport flash.events.KeyboardEvent;\n\t\n\t/**\n\t * Keeps track of what keys are pressed an"
},
{
"path": "org/flixel/system/input/Mouse.as",
"chars": 9806,
"preview": "package org.flixel.system.input\n{\n\timport flash.display.Bitmap;\n\timport flash.display.Sprite;\n\timport flash.events.Mouse"
},
{
"path": "org/flixel/system/replay/FrameRecord.as",
"chars": 3249,
"preview": "package org.flixel.system.replay\n{\n\t\n\t/**\n\t * Helper class for the new replay system. Represents all the game inputs fo"
},
{
"path": "org/flixel/system/replay/MouseRecord.as",
"chars": 933,
"preview": "package org.flixel.system.replay\n{\n\t/**\n\t * A helper class for the frame records, part of the replay/demo/recording syst"
},
{
"path": "todo.txt",
"chars": 4243,
"preview": "\n\nx +assets Player\nx +assets Grass eating animation\nx +assets Farmer\nx +assets Shovel/Build animation\nx +assets Rabbit w"
},
{
"path": "weathers.json",
"chars": 15381,
"preview": "{\n \"NIGHTTEMP\":\n {\n \"saturation\": \"0.0\", \n \"darkness\": \"0.2\", \n \"sky\": \"0xFF6a6d55\", \n \"sunTint\": \"0xfffff"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the noio/kingdom GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 118 files (708.4 KB), approximately 216.9k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.