Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import com.stencyl.graphics.G;
- import com.stencyl.graphics.BitmapWrapper;
- import com.stencyl.graphics.ScaleMode;
- import com.stencyl.behavior.Script;
- import com.stencyl.behavior.Script.*;
- import com.stencyl.behavior.ActorScript;
- import com.stencyl.behavior.SceneScript;
- import com.stencyl.behavior.TimedTask;
- import com.stencyl.models.Actor;
- import com.stencyl.models.GameModel;
- import com.stencyl.models.actor.Animation;
- import com.stencyl.models.actor.ActorType;
- import com.stencyl.models.actor.Collision;
- import com.stencyl.models.actor.Group;
- import com.stencyl.models.Scene;
- import com.stencyl.models.Sound;
- import com.stencyl.models.Region;
- import com.stencyl.models.Font;
- import com.stencyl.models.Joystick;
- import com.stencyl.Config;
- import com.stencyl.Engine;
- import com.stencyl.Input;
- import com.stencyl.Key;
- import com.stencyl.utils.motion.*;
- import com.stencyl.utils.Utils;
- import openfl.ui.Mouse;
- import openfl.display.Graphics;
- import openfl.display.BlendMode;
- import openfl.display.BitmapData;
- import openfl.display.Bitmap;
- import openfl.events.Event;
- import openfl.events.KeyboardEvent;
- import openfl.events.TouchEvent;
- import openfl.net.URLLoader;
- import box2D.common.math.B2Vec2;
- import box2D.dynamics.B2Body;
- import box2D.dynamics.B2Fixture;
- import box2D.dynamics.joints.B2Joint;
- import com.stencyl.graphics.shaders.BasicShader;
- import com.stencyl.graphics.shaders.GrayscaleShader;
- import com.stencyl.graphics.shaders.SepiaShader;
- import com.stencyl.graphics.shaders.InvertShader;
- import com.stencyl.graphics.shaders.GrainShader;
- import com.stencyl.graphics.shaders.ExternalShader;
- import com.stencyl.graphics.shaders.InlineShader;
- import com.stencyl.graphics.shaders.BlurShader;
- import com.stencyl.graphics.shaders.SharpenShader;
- import com.stencyl.graphics.shaders.ScanlineShader;
- import com.stencyl.graphics.shaders.CSBShader;
- import com.stencyl.graphics.shaders.HueShader;
- import com.stencyl.graphics.shaders.TintShader;
- import com.stencyl.graphics.shaders.BloomShader;
- class Design_39_39_Character extends ActorScript
- {
- public var _player:String;
- public var _speed:Float;
- public var _OnGround:Bool;
- public var _Moving:Bool;
- public var _speedfxhue:Float;
- public var _bouncing:Bool;
- public var _slope:Bool;
- public var _speedboost:Float;
- public var _crouching:Bool;
- public var _powercooldown:Bool;
- public var _power3POWER:Float;
- public function new(dummy:Int, actor:Actor, dummy2:Engine)
- {
- super(actor);
- nameMap.set("Actor", "actor");
- nameMap.set("player", "_player");
- _player = "p1";
- nameMap.set("speed", "_speed");
- _speed = 0.0;
- nameMap.set("OnGround", "_OnGround");
- _OnGround = false;
- nameMap.set("Moving", "_Moving");
- _Moving = false;
- nameMap.set("speed_fx_hue", "_speedfxhue");
- _speedfxhue = 0.0;
- nameMap.set("bouncing", "_bouncing");
- _bouncing = false;
- nameMap.set("slope", "_slope");
- _slope = false;
- nameMap.set("speed_boost", "_speedboost");
- _speedboost = 0.0;
- nameMap.set("crouching", "_crouching");
- _crouching = false;
- nameMap.set("power_cooldown", "_powercooldown");
- _powercooldown = false;
- nameMap.set("power_3_POWER", "_power3POWER");
- _power3POWER = 0.0;
- }
- override public function init()
- {
- /* ======================== When Creating ========================= */
- actor.makeAlwaysSimulate();
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if(((Engine.engine.getGameAttribute("SpeedStat") : Float) == 1))
- {
- Engine.engine.setGameAttribute("p1_base_speed", 25);
- }
- else if(((Engine.engine.getGameAttribute("SpeedStat") : Float) == 2))
- {
- Engine.engine.setGameAttribute("p1_base_speed", 45);
- }
- else if(((Engine.engine.getGameAttribute("SpeedStat") : Float) == 3))
- {
- Engine.engine.setGameAttribute("p1_base_speed", 65);
- }
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if(isKeyDown("R"))
- {
- return;
- }
- else if((((Engine.engine.getGameAttribute("power_id") : Float) == 3) && _powercooldown))
- {
- return;
- }
- else if((isKeyDown("L") && !(_crouching)))
- {
- _speedboost = 0;
- _Moving = true;
- Engine.engine.setGameAttribute("Dir", "L");
- actor.setXVelocity(-((asNumber((getGameAttribute(((_player) + ("_base_speed"))))) + _speed)));
- if(((actor.getYVelocity() == 0) && _OnGround))
- {
- actor.setAnimation("L_Moving");
- }
- }
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("L", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && released)
- {
- if(isKeyDown("R"))
- {
- return;
- }
- else
- {
- _Moving = false;
- actor.setXVelocity((actor.getXVelocity() / 2));
- runLater(1000 * .1, function(timeTask:TimedTask):Void
- {
- actor.setXVelocity(0);
- }, actor);
- }
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if(isKeyDown("L"))
- {
- return;
- }
- else if((((Engine.engine.getGameAttribute("power_id") : Float) == 3) && _powercooldown))
- {
- return;
- }
- else if((isKeyDown("R") && !(_crouching)))
- {
- _speedboost = 0;
- _Moving = true;
- Engine.engine.setGameAttribute("Dir", "R");
- actor.setXVelocity((asNumber((getGameAttribute(((_player) + ("_base_speed"))))) + _speed));
- if(((actor.getYVelocity() == 0) && _OnGround))
- {
- actor.setAnimation("R_Moving");
- }
- }
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("R", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && released)
- {
- if(isKeyDown("L"))
- {
- return;
- }
- else
- {
- _Moving = false;
- actor.setXVelocity((actor.getXVelocity() / 2));
- runLater(1000 * .1, function(timeTask:TimedTask):Void
- {
- actor.setXVelocity(0);
- }, actor);
- }
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("L", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && released)
- {
- abortTweenNumber("_speed");
- _speed = 0;
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("R", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && released)
- {
- abortTweenNumber("_speed");
- _speed = 0;
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("L", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && pressed)
- {
- runLater(1000 * .1, function(timeTask:TimedTask):Void
- {
- if((_Moving == true))
- {
- var attributeTween = attributeTweens.get("_speed");
- if(attributeTween == null)
- {
- attributeTween = new TweenFloat();
- attributeTween.doOnUpdate(function() {_speed = attributeTween.value;});
- attributeTweens.set("_speed", attributeTween);
- }
- attributeTween.tween(_speed, 100, Easing.quadInOut, Std.int(2*1000));
- }
- }, actor);
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("R", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && pressed)
- {
- runLater(1000 * .1, function(timeTask:TimedTask):Void
- {
- if((_Moving == true))
- {
- var attributeTween = attributeTweens.get("_speed");
- if(attributeTween == null)
- {
- attributeTween = new TweenFloat();
- attributeTween.doOnUpdate(function() {_speed = attributeTween.value;});
- attributeTweens.set("_speed", attributeTween);
- }
- attributeTween.tween(_speed, 100, Easing.quadInOut, Std.int(2*1000));
- }
- }, actor);
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if((actor.getXVelocity() == 0))
- {
- _speed = (_speed / 2);
- if(((Engine.engine.getGameAttribute("Dir") : String) == "L"))
- {
- actor.setAnimation("L_Idle");
- }
- else if(((Engine.engine.getGameAttribute("Dir") : String) == "R"))
- {
- actor.setAnimation("R_Idle");
- }
- }
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- engine.cameraFollow(actor);
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("A", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && pressed)
- {
- if(((actor.getYVelocity() == 0) && _OnGround))
- {
- actor.applyImpulse(0, -1, 110);
- _slope = false;
- playSound(getSound(66));
- }
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if((actor.getYVelocity() < 0))
- {
- if((((Engine.engine.getGameAttribute("Dir") : String) == "L") || (actor.getAnimation() == "L_Idle")))
- {
- actor.setAnimation("L_Jump");
- }
- else if((((Engine.engine.getGameAttribute("Dir") : String) == "R") || (actor.getAnimation() == "R_Idle")))
- {
- actor.setAnimation("R_Jump");
- }
- }
- if((actor.getYVelocity() > 0))
- {
- if((((Engine.engine.getGameAttribute("Dir") : String) == "L") || (actor.getAnimation() == "L_Idle")))
- {
- actor.setAnimation("L_Fall");
- }
- else if((((Engine.engine.getGameAttribute("Dir") : String) == "R") || (actor.getAnimation() == "R_Idle")))
- {
- actor.setAnimation("R_Fall");
- }
- }
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if(((_OnGround && (actor.getYVelocity() == 0)) && !(_Moving)))
- {
- actor.setAnimation((((Engine.engine.getGameAttribute("Dir") : String)) + ("_Idle")));
- actor.setXVelocity(0);
- }
- }
- });
- /* ======================== Something Else ======================== */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if(event.thisFromBottom)
- {
- _OnGround = true;
- }
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if(!(actor.getYVelocity() == 0))
- {
- _OnGround = false;
- }
- }
- });
- /* ======================== Actor of Type ========================= */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && sameAsAny(getActorType(63), event.otherActor.getType(),event.otherActor.getGroup()))
- {
- if(!(_bouncing))
- {
- _bouncing = true;
- actor.setYVelocity(0);
- playSound(getSound(67));
- if(((Engine.engine.getGameAttribute("Dir") : String) == "R"))
- {
- actor.applyImpulse(1, 0, 20);
- _speed = (_speed + 20);
- }
- else if(((Engine.engine.getGameAttribute("Dir") : String) == "L"))
- {
- actor.applyImpulse(1, 0, -20);
- _speed = (_speed - 20);
- }
- if(isKeyDown("A"))
- {
- actor.applyImpulse(0, -1, 180);
- }
- else
- {
- actor.applyImpulse(0, -1, 110);
- }
- runLater(1000 * .4, function(timeTask:TimedTask):Void
- {
- _bouncing = false;
- }, actor);
- }
- }
- });
- /* ======================== Actor of Type ========================= */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && sameAsAny(getActorType(71), event.otherActor.getType(),event.otherActor.getGroup()))
- {
- playSound(getSound(102));
- event.otherActor.setAnimation("Broken");
- event.otherActor.setXVelocity((event.thisActor.getXVelocity() / 1.4));
- event.otherActor.applyImpulse(0, -1, 10);
- }
- });
- /* ======================= Member of Group ======================== */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && sameAsAny(getActorGroup(5),event.otherActor.getType(),event.otherActor.getGroup()))
- {
- if((_Moving && ((Engine.engine.getGameAttribute("Dir") : String) == "R")))
- {
- event.thisActor.setY((event.thisActor.getY() - 5));
- }
- }
- });
- /* ======================= Member of Group ======================== */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && sameAsAny(getActorGroup(6),event.otherActor.getType(),event.otherActor.getGroup()))
- {
- if((_Moving && ((Engine.engine.getGameAttribute("Dir") : String) == "L")))
- {
- event.thisActor.setY((event.thisActor.getY() - 5));
- }
- }
- });
- /* ======================== Actor of Type ========================= */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && sameAsAny(getActorType(123), event.otherActor.getType(),event.otherActor.getGroup()))
- {
- if(event.otherFromTop)
- {
- playSound(getSound(139));
- if((actor.getXVelocity() == 0))
- {
- actor.moveBy(0, -480, .1, Easing.quadIn);
- }
- else if(((Engine.engine.getGameAttribute("Dir") : String) == "L"))
- {
- actor.moveBy((actor.getXVelocity() / 2.2), -480, .1, Easing.quadIn);
- }
- else if(((Engine.engine.getGameAttribute("Dir") : String) == "R"))
- {
- actor.moveBy((actor.getXVelocity() / 2.2), -480, .1, Easing.quadIn);
- }
- if(((Engine.engine.getGameAttribute("LevelTime") : String) == "Day"))
- {
- setColorBackground(Utils.getColorRGB(255,255,255));
- runLater(1000 * .2, function(timeTask:TimedTask):Void
- {
- setColorBackground(Utils.getColorRGB(91,168,255));
- }, actor);
- }
- else if(((Engine.engine.getGameAttribute("LevelTime") : String) == "Night"))
- {
- setColorBackground(Utils.getColorRGB(255,255,255));
- runLater(1000 * .2, function(timeTask:TimedTask):Void
- {
- setColorBackground(Utils.getColorRGB(0,0,0));
- }, actor);
- }
- }
- }
- });
- /* ======================== Actor of Type ========================= */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && sameAsAny(getActorType(141), event.otherActor.getType(),event.otherActor.getGroup()))
- {
- recycleActor(event.otherActor);
- Engine.engine.setGameAttribute("note_count", ((Engine.engine.getGameAttribute("note_count") : Float) + 1));
- }
- });
- /* ======================= Member of Group ======================== */
- addCollisionListener(actor, function(event:Collision, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && sameAsAny(getActorGroup(7),event.otherActor.getType(),event.otherActor.getGroup()))
- {
- event.otherActor.growTo(0/100, 0/100, .08, Easing.elasticInOut);
- Engine.engine.setGameAttribute("power_id", asNumber(event.otherActor.getAnimation()));
- runLater(1000 * 2, function(timeTask:TimedTask):Void
- {
- recycleActor(event.otherActor);
- }, actor);
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- if(isKeyDown("D"))
- {
- if(((actor.getAnimation() == "L_Idle") || (actor.getAnimation() == "R_Idle")))
- {
- actor.setCurrentFrame(1);
- _crouching = true;
- }
- else
- {
- return;
- }
- }
- else
- {
- _crouching = false;
- }
- }
- });
- /* ======================== When Updating ========================= */
- addWhenUpdatedListener(null, function(elapsedTime:Float, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled)
- {
- Engine.engine.setGameAttribute("p1_speed", _speed);
- }
- });
- /* =========================== Keyboard =========================== */
- addKeyStateListener("B", function(pressed:Bool, released:Bool, list:Array<Dynamic>):Void
- {
- if(wrapper.enabled && pressed)
- {
- if((((Engine.engine.getGameAttribute("power_id") : Float) == 3) && !(_powercooldown)))
- {
- actor.setFilter([createBrightnessFilter(70)]);
- actor.growTo(90/100, 90/100, .01, Easing.quadIn);
- actor.setFilter([createTintFilter(Utils.getColorRGB(204,255,255), 70/100)]);
- _powercooldown = true;
- if((!(isKeyDown("R")) && !(isKeyDown("L"))))
- {
- _Moving = true;
- }
- runLater(1000 * .08, function(timeTask:TimedTask):Void
- {
- actor.growTo(100/100, 100/100, .02, Easing.quadIn);
- actor.clearFilters();
- actor.setYVelocity((actor.getYVelocity() / 5));
- actor.setXVelocity((actor.getXVelocity() / 5));
- if((!(isKeyDown("L")) && !(isKeyDown("R"))))
- {
- _Moving = false;
- }
- else
- {
- var attributeTween = attributeTweens.get("_speed");
- if(attributeTween == null)
- {
- attributeTween = new TweenFloat();
- attributeTween.doOnUpdate(function() {_speed = attributeTween.value;});
- attributeTweens.set("_speed", attributeTween);
- }
- attributeTween.tween(_speed, 100, Easing.quadInOut, Std.int(2*1000));
- }
- }, actor);
- runLater(1000 * .09, function(timeTask:TimedTask):Void
- {
- _powercooldown = false;
- }, actor);
- _power3POWER = (actor.getXVelocity() + 350);
- if((isKeyDown("U") && isKeyDown("R")))
- {
- actor.applyImpulse(1, -1, _power3POWER);
- }
- else if((isKeyDown("U") && isKeyDown("L")))
- {
- actor.applyImpulse(-1, -1, _power3POWER);
- }
- else if((isKeyDown("D") && isKeyDown("R")))
- {
- actor.applyImpulse(1, 1, _power3POWER);
- }
- else if((isKeyDown("D") && isKeyDown("L")))
- {
- actor.applyImpulse(-1, 1, _power3POWER);
- }
- else if(isKeyDown("L"))
- {
- actor.applyImpulse(-1, 0, _power3POWER);
- }
- else if(isKeyDown("D"))
- {
- actor.applyImpulse(0, 1, _power3POWER);
- }
- else if(isKeyDown("U"))
- {
- actor.applyImpulse(0, -1, _power3POWER);
- }
- else if(isKeyDown("R"))
- {
- actor.applyImpulse(1, 0, _power3POWER);
- }
- else
- {
- if(((Engine.engine.getGameAttribute("Dir") : String) == "R"))
- {
- actor.applyImpulse(1, 0, _power3POWER);
- }
- else if(((Engine.engine.getGameAttribute("Dir") : String) == "L"))
- {
- actor.applyImpulse(-1, 0, _power3POWER);
- }
- }
- }
- }
- });
- }
- override public function forwardMessage(msg:String)
- {
- }
- }
Add Comment
Please, Sign In to add comment