initial commit, kind of working.

This commit is contained in:
2026-10-10 15:50:17 -06:00
commit 4db96b0bae
1041 changed files with 51423 additions and 0 deletions
@@ -0,0 +1,503 @@
package com.arc.dh.state
{
import Playtomic.Log;
import com.arc.dh.Color;
import com.arc.dh.entities.Player;
import com.arc.dh.entities.PlayerTadpole;
import com.arc.dh.menu.GameOver;
import com.arc.dh.objects.*;
import com.arc.dh.objects.enemies.Tadpole;
import com.arc.dh.util.AchievementSystem;
import com.arc.dh.util.Config;
import com.arc.dh.util.Data;
import com.arc.dh.util.DataSerializer;
import com.arc.dh.util.Sound;
import com.arc.dh.util.SoundSystem;
import com.arc.flixel.ArcParticleSystem;
import com.arc.flixel.ArcU;
import flash.display.BitmapData;
import org.flixel.FlxG;
import org.flixel.FlxObject;
import org.flixel.FlxPoint;
import org.flixel.FlxTilemap;
import org.flixel.system.FlxTile;
public class TadpoleMode extends HorizontalMode
{
protected static const ESCAPE_SPRITE:Class = TadpoleMode_ESCAPE_SPRITE;
protected static const ESCAPE_OVERLAY_SPRITE:Class = TadpoleMode_ESCAPE_OVERLAY_SPRITE;
protected static const LAVA_SPRITE:Class = TadpoleMode_LAVA_SPRITE;
private static const RUN_WIDTH:int = 4000;
private static const RUN_HEIGHT:int = 20;
private static const PLAYER_OFFSET:int = 60;
public var tadpole:PlayerTadpole;
private var _gameOver:GameOver;
private var lastSeed:int = 0;
public function TadpoleMode()
{
super();
Log.CustomMetric("TadpoleStart","Modes");
mode = TADPOLE_MODE;
_ch = ArcU.rand(1,7);
}
override public function create() : void
{
super.create();
bg1.vertical = bg2.vertical = bg3.vertical = false;
camera = new Camera(FlxG.width / 2,FlxG.height / 2);
camera.velocity.x = 100;
this.add(camera);
this.tadpole = new PlayerTadpole(36,120);
this.add(this.tadpole);
this.remove(player);
this.add(player);
player.visible = false;
player.solid = true;
player.controllable = false;
player.width = player.height = 2;
player.offset.x += 4;
player.offset.y += 4;
controlCharacter = false;
FlxG.camera.follow(camera);
FlxG.camera.update();
FlxG.worldBounds.width = pixels.width * Config.BLOCK_SIZE;
FlxG.worldBounds.height = pixels.height * Config.BLOCK_SIZE;
spawnChance = 100;
SoundSystem.music(Sound.PLAY_MUSIC);
}
override protected function getStartX() : int
{
return 36;
}
override protected function getStartY() : int
{
return 48;
}
override public function update() : void
{
if(_complete)
{
this._gameOver.update();
showAchievement();
return;
}
super.update();
if(inMenu)
{
return;
}
player.x = this.tadpole.x + 6;
player.y = this.tadpole.y - 3;
if(camera.velocity.x < 150)
{
camera.velocity.x += FlxG.elapsed * 8;
}
if(camera.velocity.x < 200)
{
camera.velocity.x += FlxG.elapsed * 5;
}
else if(camera.velocity.x < 300)
{
camera.velocity.x += FlxG.elapsed * 3;
}
else
{
camera.velocity.x += FlxG.elapsed;
}
if(camera.velocity.x > 500)
{
camera.velocity.x = 500;
}
if(ArcU.rand(1,100) < 5)
{
}
if(player.x < FlxG.camera.scroll.x + PLAYER_OFFSET - 2)
{
player.velocity.x = camera.velocity.x * 1.2;
}
else if(player.x > FlxG.camera.scroll.x + PLAYER_OFFSET + 2)
{
player.velocity.x = camera.velocity.x * 0.9;
}
else
{
player.velocity.x = camera.velocity.x;
player.x = FlxG.camera.scroll.x + PLAYER_OFFSET;
}
if(_dieTimer > 0)
{
_dieTimer -= FlxG.elapsed;
this.tadpole.alpha = _dieTimer;
camera.velocity.x = 0;
if(_dieTimer <= 0)
{
this.tadpole.alpha = 0;
this.die();
}
}
this.tadpole.x = FlxG.camera.scroll.x + PLAYER_OFFSET;
if(player.getScreenXY().x < -player.width)
{
Data.hp = 0;
Data.state.die();
}
}
override protected function createLevel() : void
{
tilemap = this.buildLevel();
tilemap.follow();
}
public function predie() : void
{
var _loc1_:FlxPoint = null;
if(!this.tadpole.isDead())
{
_dieTimer = 1.2;
this.tadpole.die();
_loc1_ = this.tadpole.getMidpoint();
ArcParticleSystem.emit(Data.state.particles,Color.BLUE,_loc1_.x,_loc1_.y,20,2,0,0,-200,200,-200,200);
ArcParticleSystem.emit(Data.state.particles,Color.WHITE,_loc1_.x,_loc1_.y,20,2,0,0,-200,200,-200,200);
}
}
override public function die() : void
{
_complete = true;
inMenu = false;
SoundSystem.play(Sound.WIN);
this._gameOver = new GameOver(cdiamonds.toString(),this.caveHeight.toString() + "M",duration).setCallback(function():void
{
FlxG.mouse.hide();
FlxG.switchState(new TadpoleMode());
},function():void
{
FlxG.mouse.hide();
FlxG.switchState(new MainMenu(0));
});
if(this.caveHeight > Data.maxTadpoleDistance)
{
Data.maxTadpoleDistance = this.caveHeight;
}
DataSerializer.save();
Data.kong();
Newgrounds.medals();
}
override public function reset() : void
{
}
override public function restart() : void
{
var _loc2_:StoryDialog = null;
var _loc1_:Array = checkpoints[checkpoints.length - 1];
player.reset(_loc1_[0] * Config.BLOCK_SIZE + 4,_loc1_[1] * Config.BLOCK_SIZE + 12);
FlxG.camera.focusOn(new FlxPoint(player.x,player.y));
FlxG.camera.follow(player);
Data.hp = Data.hpm;
boss = 0;
spawner = new Object();
pixels = mpixels.clone();
for each(_loc2_ in messages)
{
_loc2_.load();
}
bullets.clear();
enemies.clear();
penemies.clear();
diamonds.clear();
powerups.clear();
damagetexts.clear();
healthbars.clear();
objects.clear();
cobjects.clear();
spawnTop = this.calcTop(Config.SPAWN_PADDING);
spawnBottom = this.calcBottom(Config.SPAWN_PADDING);
despawnTop = player.y / Config.BLOCK_SIZE;
despawnBottom = player.y / Config.BLOCK_SIZE + 1;
}
private function buildLevel() : FlxTilemap
{
var waterFunction:Function;
var map:FlxTilemap = null;
var tileArray:Array = this.createRandomMap();
var tileCSV:String = FlxTilemap.arrayToCSV(tileArray,pixels.width);
map = new FlxTilemap();
map.loadMap(tileCSV,PlayMode["T" + _ch],Config.BLOCK_SIZE,Config.BLOCK_SIZE,0,0,1,80);
map.setTileProperties(52,FlxObject.ANY,function(param1:FlxTile, param2:FlxObject):void
{
var _loc3_:int = 0;
if(param2 is Bullet)
{
ArcParticleSystem.emit(Data.state.particles,"wooden_crate",param1.x,param1.y,10,1,5,400,-100,100,-100,-40,param1.width,param1.height);
map.setTileByIndex(param1.mapIndex,0,true);
_loc3_ = ArcU.rand(0,100);
if(_loc3_ >= 80)
{
if(_loc3_ < 99)
{
addDiamonds(param1.x,param1.y,ArcU.rand(1,2 * _ch));
}
else
{
createHeart(param1.x,param1.y);
}
}
++Data.boxes;
SoundSystem.play(Sound.BOX,0.4);
AchievementSystem.boxes();
}
});
map.setTileProperties(53,FlxObject.ANY,function(param1:FlxTile, param2:FlxObject):void
{
var _loc3_:int = 0;
if(param2 is Missile)
{
ArcParticleSystem.emit(Data.state.particles,"steel_crate",param1.x,param1.y,10,1,5,800,-100,100,-200,-80,param1.width,param1.height);
map.setTileByIndex(param1.mapIndex,0,true);
_loc3_ = ArcU.rand(0,100);
if(_loc3_ >= 50)
{
if(_loc3_ < 99)
{
addDiamonds(param1.x,param1.y,ArcU.rand(1,2 * _ch));
}
else
{
createHeart(param1.x,param1.y);
}
}
++Data.boxes;
SoundSystem.play(Sound.STEELBOX);
AchievementSystem.boxes();
}
});
waterFunction = function(param1:FlxTile, param2:FlxObject):void
{
var _loc3_:Player = param2 as Player;
if(_loc3_ == null)
{
return;
}
_loc3_.inWater();
};
map.setTileProperties(12,FlxObject.NONE,waterFunction,Player);
map.setTileProperties(56,FlxObject.ANY);
return map;
}
private function imageToTileArray(param1:BitmapData, param2:BitmapData) : Array
{
var _loc5_:int = 0;
var _loc6_:uint = 0;
var _loc7_:int = 0;
this.pixels = param1;
this.overpixels = param2;
var _loc3_:Array = new Array();
mpixels = param1.clone();
var _loc4_:int = 0;
while(_loc4_ < param1.height)
{
_loc5_ = 0;
while(_loc5_ < param1.width)
{
_loc6_ = getLayerTile(_loc5_,_loc4_,true);
_loc7_ = colorToTileID(_loc6_,_loc5_,_loc4_);
_loc3_.push(_loc7_);
_loc5_++;
}
_loc4_++;
}
return _loc3_;
}
private function createRandomMap() : Array
{
var _loc3_:int = 0;
var _loc4_:int = 0;
var _loc13_:int = 0;
var _loc1_:BitmapData = new BitmapData(RUN_WIDTH,RUN_HEIGHT,false,10052885);
var _loc2_:BitmapData = new BitmapData(RUN_WIDTH,RUN_HEIGHT,false);
var _loc5_:int = 14;
var _loc6_:int = 3;
var _loc7_:Boolean = false;
var _loc8_:Boolean = false;
var _loc9_:int = 0;
var _loc10_:int = 0;
var _loc11_:int = 0;
var _loc12_:int = 0;
_loc3_ = 0;
while(_loc3_ < RUN_WIDTH)
{
_loc10_ = _loc3_ / 9;
_loc4_ = _loc6_;
while(_loc4_ < _loc6_ + _loc5_)
{
_loc1_.setPixel(_loc3_,_loc4_,16777215);
_loc12_ = ArcU.rand(1,10000);
if(_loc4_ < _loc6_ + _loc5_ - 2)
{
if(_loc12_ < 600)
{
_loc1_.setPixel(_loc3_,_loc4_,16763904);
}
else if(_loc12_ >= 1000)
{
if(_loc12_ < 1010 && _loc3_ > 30)
{
_loc1_.setPixel(_loc3_,_loc4_,16747367);
}
else if(_loc12_ < 1012 && _loc3_ > 30)
{
_loc1_.setPixel(_loc3_,_loc4_,6473198);
}
else if(_loc12_ < 1014 && _loc3_ > 30)
{
_loc1_.setPixel(_loc3_,_loc4_,6746111);
}
}
}
_loc4_++;
}
_loc1_.setPixel(_loc3_,_loc4_ - 1,5228053);
if(ArcU.rand(1,100) < 10 && _loc3_ > 30 && _loc11_ < _loc3_ - ArcU.clamp(40 - _loc3_ / 50,10,40))
{
_loc1_.setPixel(_loc3_,ArcU.rand(_loc6_ + 2,_loc6_ + _loc5_ - 3),15763712);
_loc11_ = _loc3_;
}
_loc13_ = ArcU.rand(-1,1);
if(_loc13_ != 0 && _loc9_ != 0 && _loc13_ != _loc9_)
{
_loc13_ = 0;
}
_loc9_ = _loc13_;
_loc6_ += _loc13_;
_loc6_ = ArcU.clamp(_loc6_,2,18 - _loc5_);
if(_loc10_ < 30)
{
_loc5_ = 14;
}
else if(_loc10_ < 60)
{
_loc5_ = 13;
}
else if(_loc10_ < 110)
{
_loc5_ = 12;
}
else if(_loc10_ < 160)
{
_loc5_ = 11;
}
else if(_loc10_ < 300)
{
_loc5_ = 10;
}
else if(_loc10_ < 500)
{
_loc5_ = 9;
}
else if(_loc10_ < 700)
{
_loc5_ = 8;
}
else if(_loc10_ < 900)
{
_loc5_ = 7;
}
else if(_loc10_ < 1200)
{
_loc5_ = 6;
}
else
{
_loc5_ = 5;
}
_loc3_++;
}
return this.imageToTileArray(_loc1_,_loc2_);
}
override public function draw() : void
{
var _loc1_:FlxPoint = this.tadpole.getScreenXY();
var _loc2_:int = _loc1_.x - PLAYER_OFFSET;
this.tadpole.x -= _loc2_;
super.draw();
if(_complete && this._gameOver != null)
{
this._gameOver.draw();
}
}
override protected function parallax() : void
{
var _loc1_:Background = null;
var _loc2_:int = 0;
for each(_loc1_ in [bg1,bg2,bg3])
{
_loc2_ = _loc1_.getScreenXY().x;
if(_loc2_ < -360)
{
_loc1_.x = FlxG.camera.scroll.x * _loc1_.scrollFactor.x + (_loc2_ > 0 && _loc2_ < 1000 ? _loc2_ : 0);
}
else if(_loc2_ > 0)
{
_loc1_.x = FlxG.camera.scroll.x * _loc1_.scrollFactor.x - 360 + (_loc2_ > 0 && _loc2_ < 1000 ? _loc2_ : 0);
}
}
}
override public function get caveHeight() : int
{
return player.x / 9;
}
override protected function calcTop(param1:int) : int
{
return FlxG.camera.scroll.x / Config.BLOCK_SIZE - param1;
}
override protected function calcBottom(param1:int) : int
{
return (FlxG.camera.scroll.x + FlxG.width) / Config.BLOCK_SIZE + param1;
}
override protected function spawn(param1:int) : void
{
var _loc3_:Tadpole = null;
super.spawn(param1);
var _loc2_:int = 10 + param1 / 50;
_loc2_ = ArcU.clamp(_loc2_,10,30);
if(ArcU.rand(1,100) < _loc2_ && param1 > 30 && param1 > this.lastSeed + 3)
{
_loc3_ = new Tadpole(param1,ArcU.rand(4,16),1);
_loc3_.loadRotatedGraphic(Tadpole.redSprite,60,-1,true,true);
_loc3_.red = true;
_loc3_.width = _loc3_.height = 10;
_loc3_.offset.x = _loc3_.offset.y = 6;
_loc3_.move(180);
enemies.add(_loc3_);
this.lastSeed = param1;
}
}
}
}