Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SplatterDash committed Nov 30, 2024
2 parents f46d9b8 + 55fb415 commit 072bd95
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 59 deletions.
Binary file added assets/images/presents/present-censored.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
47 changes: 34 additions & 13 deletions source/Ctrl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import openfl.Assets;
*/
class Ctrl
{
//for switch, mainly
// for switch, mainly
static var REVERSE_MENU_CONTROLS:Bool = false;

// controls are handled as an array of bools
Expand Down Expand Up @@ -59,8 +59,6 @@ class Ctrl

public static var releaseHolds:Array<Bool> = [false];

public static var controlModes:Array<String> = ["", "CONTROLLER", "CONTROLLER"];

public static var p1controller:FlxGamepad;
public static var p2controller:FlxGamepad;

Expand All @@ -73,6 +71,8 @@ class Ctrl

static var controlLock:Int = 0;

public static var mode:ControlMode = ControlModes.INITIAL;

public function new()
{
// Nothing
Expand All @@ -94,7 +94,7 @@ class Ctrl
// ProgressManager("keys_load");
#if switch
model = "switch";
REVERSE_MENU_CONTROLS=true;
REVERSE_MENU_CONTROLS = true;
#end
}

Expand All @@ -120,11 +120,11 @@ class Ctrl
interact[c] = FlxG.keys.anyPressed([controls[c][4]]);
jinteract[c] = FlxG.keys.anyJustPressed([controls[c][4]]);
rinteract[c] = FlxG.keys.anyJustReleased([controls[c][4]]);

menu[c] = FlxG.keys.anyPressed([controls[c][5]]);
jmenu[c] = FlxG.keys.anyJustPressed([controls[c][5]]);
rmenu[c] = FlxG.keys.anyJustReleased([controls[c][5]]);

emote[c] = FlxG.keys.anyPressed([controls[c][6]]);
jemote[c] = FlxG.keys.anyJustPressed([controls[c][6]]);
remote[c] = FlxG.keys.anyJustReleased([controls[c][6]]);
Expand Down Expand Up @@ -153,7 +153,6 @@ class Ctrl

for (p in 1...3)
{
// if (controlModes[p].indexOf("CONTROLLER") == -1) return;
var gp:FlxGamepad = null;

if (p == 1)
Expand All @@ -162,8 +161,6 @@ class Ctrl
if (p == 2)
gp = p2controller;

// debug(PlayState.coop);

if (p1controller == null && p2controller == null && p == 1)
gp = FlxG.gamepads.getFirstActiveGamepad();

Expand Down Expand Up @@ -252,9 +249,9 @@ class Ctrl

public static function allFalse()
{
// debug("All False");
// for all players
for (c in 1...3)
{ // for all players
{
setFalse(c);
}
allCleared = true;
Expand All @@ -277,11 +274,11 @@ class Ctrl
interact[c] = false;
jinteract[c] = false;
rinteract[c] = false;

menu[c] = false;
jmenu[c] = false;
rmenu[c] = false;

emote[c] = false;
jemote[c] = false;
remote[c] = false;
Expand Down Expand Up @@ -336,3 +333,27 @@ class Ctrl
}
*/
}

typedef ControlMode =
{
var can_move:Bool;
var can_emote:Bool;
var can_open_menus:Bool;
}

enum abstract ControlModes(ControlMode) from ControlMode to ControlMode
{
public static final INITIAL:ControlMode = {can_move: false, can_emote: false, can_open_menus: false};
public static final OVERWORLD:ControlMode = {can_move: true, can_emote: true, can_open_menus: true};
public static final TALKING:ControlMode = {can_move: false, can_emote: false, can_open_menus: false};
public static final MINIGAME:ControlMode = {can_move: false, can_emote: false, can_open_menus: false};

public function restrict_controls(mode:ControlMode)
{
// not implemented
switch (mode)
{
default:
}
}
}
31 changes: 15 additions & 16 deletions source/data/types/TankmasEnums.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package data.types;
import data.types.TankmasDefs.CostumeDef;
import data.types.TankmasDefs.SpriteAnimationDef;


enum abstract UnlockCondition(String) from String to String
{
/**On a specific date, data contains the unix timestamp, see: https://www.unixtimestamp.com/index.php**/
Expand All @@ -22,25 +21,24 @@ enum abstract UnlockCondition(String) from String to String
final FLAG;

public static inline function get_unlocked(condition:UnlockCondition, data:Dynamic):Bool
switch (cast(condition, UnlockCondition))
{
default:
return true;
case UnlockCondition.YOUR_A_SPECIAL_LITTLE_BOY:
return true;
case UnlockCondition.ANGRY_FAIC:
return false;
case UnlockCondition.DATE:
return Date.now().getTime() >= data; // where data is a unix timestamp, see above
case UnlockCondition.ACHIEVEMENT:
switch (cast(condition, UnlockCondition))
{
default:
return true;
case UnlockCondition.YOUR_A_SPECIAL_LITTLE_BOY:
return true;
case UnlockCondition.ANGRY_FAIC:
return false;
case UnlockCondition.DATE:
return Date.now().getTime() >= data; // where data is a unix timestamp, see above
case UnlockCondition.ACHIEVEMENT:
return true;
// TODO: insert code that handles achievements from NG API here
// TODO: insert code that handles achievements from NG API here
case UnlockCondition.FLAG:
return Flags.get(data);
}
}
}


/**
* Enum of fixed player animations, probably will be moved
*/
Expand Down Expand Up @@ -130,6 +128,7 @@ enum abstract PlayerAnimation(SpriteAnimationDef) from SpriteAnimationDef to Spr
]
};
}

/**
* Enum of fixed player animations, probably will be moved
*/
Expand Down Expand Up @@ -336,4 +335,4 @@ enum abstract PresentAnimation(SpriteAnimationDef) from SpriteAnimationDef to Sp
}
]
};
}
}
42 changes: 23 additions & 19 deletions source/entities/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,36 @@ class Player extends BaseUser
final DOWN:Bool = Ctrl.down[1];
final LEFT:Bool = Ctrl.left[1];
final RIGHT:Bool = Ctrl.right[1];

final NO_KEYS:Bool = !UP && !DOWN && !LEFT && !RIGHT;

if (Ctrl.jemote[1] && !MinigameHandler.instance.is_minigame_active())
use_sticker(sticker);
// keeping the sheet menus right next to each other makes sense, no?

if (UP)
velocity.y -= move_speed / move_acl * (velocity.y > 0 ? 1 : move_reverse_mod);
else if (DOWN)
velocity.y += move_speed / move_acl * (velocity.y < 0 ? 1 : move_reverse_mod);

if (LEFT)
velocity.x -= move_speed / move_acl * (velocity.x > 0 ? 1 : move_reverse_mod);
else if (RIGHT)
velocity.x += move_speed / move_acl * (velocity.x < 0 ? 1 : move_reverse_mod);

if (!LEFT && !RIGHT)
velocity.x = velocity.x * .95;
else
flipX = RIGHT;
// flipX = velocity.x > 0;

if (!UP && !DOWN)
velocity.y = velocity.y * move_no_input_drag;
if (Ctrl.mode.can_move)
{
if (UP)
velocity.y -= move_speed / move_acl * (velocity.y > 0 ? 1 : move_reverse_mod);
else if (DOWN)
velocity.y += move_speed / move_acl * (velocity.y < 0 ? 1 : move_reverse_mod);

if (LEFT)
velocity.x -= move_speed / move_acl * (velocity.x > 0 ? 1 : move_reverse_mod);
else if (RIGHT)
velocity.x += move_speed / move_acl * (velocity.x < 0 ? 1 : move_reverse_mod);

if (!LEFT && !RIGHT)
velocity.x = velocity.x * .95;
else
flipX = RIGHT;
// flipX = velocity.x > 0;

if (!UP && !DOWN)
velocity.y = velocity.y * move_no_input_drag;
}

move_animation_handler(!NO_KEYS);
move_animation_handler(!NO_KEYS && Ctrl.mode.can_move);

// move_animation_handler(velocity.x.abs() + velocity.y.abs() > 10);
}
Expand Down
4 changes: 4 additions & 0 deletions source/entities/Present.hx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class Present extends Interactable

PlayState.self.presents.add(this);
thumbnail = new Thumbnail(x, y - 200, Paths.get((content + (comic ? '-0' : '') + '.png')));

#if censor_presents
thumbnail.color = FlxColor.BLACK;
#end
}

override function kill()
Expand Down
23 changes: 16 additions & 7 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class PlayState extends BaseState
override public function create()
{
super.create();

Ctrl.mode = ControlModes.OVERWORLD;

self = this;

OnlineLoop.init();
Expand Down Expand Up @@ -128,13 +131,19 @@ class PlayState extends BaseState
super.update(elapsed);
// Ctrl.update();

#if dev
if (Ctrl.reset[1])
FlxG.switchState(new PlayState());
#end

if (Ctrl.mode.can_open_menus)
{
if (Ctrl.jmenu[1])
new CostumeSelectSheet();
//if (Ctrl.jemote[1])
//new StickerSelectSheet();
}

if (Ctrl.jmenu[1])
new CostumeSelectSheet();
//if (Ctrl.jemote[1])
//new StickerSelectSheet();
for (mem in ui.members)
switch (ui.members.indexOf(mem))
{
Expand All @@ -147,7 +156,7 @@ class PlayState extends BaseState
onComplete: function(twn:FlxTween)
{
twen = null;
mem.loadGraphic(Paths.get('charselect_mini_FULL.png'));
mem.loadGraphic(Paths.get('charselect-mini-full.png'));
}
});
if (FlxG.mouse.justReleased)
Expand All @@ -174,7 +183,7 @@ class PlayState extends BaseState
onComplete: function(twn:FlxTween)
{
twen = null;
mem.loadGraphic(Paths.get('charselect_mini_BG.png'));
mem.loadGraphic(Paths.get('charselect-mini-bg.png'));
}
});
}
Expand Down Expand Up @@ -230,7 +239,7 @@ class PlayState extends BaseState
{
ui.add(new FlxSpriteExt(20, 20, Paths.get('heart.png')));
ui.add(new FlxSpriteExt(1708, 20, Paths.get('settings.png')));
ui.add(new FlxSpriteExt(1520, 1030, Paths.get('charselect_mini_BG.png')));
ui.add(new FlxSpriteExt(1520, 1030, Paths.get('charselect-mini-bg.png')));
ui.forEach((spr:FlxSpriteExt) ->
{
spr.scrollFactor.set(0, 0);
Expand Down
7 changes: 6 additions & 1 deletion source/states/substates/ArtSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class ArtSubstate extends flixel.FlxSubState
{
super();
art = new FlxSprite(0, 0).loadGraphic(Paths.get('$content.png'));

#if censor_presents
art = new FlxSprite(0, 0).loadGraphic(Paths.get('present-censored.png'));
#end

art.setGraphicSize(art.width > art.height ? 1920 : 0, art.height >= art.width ? 1080 : 0);
art.updateHitbox();
art.screenCenter();
Expand Down Expand Up @@ -52,4 +57,4 @@ class ArtSubstate extends flixel.FlxSubState
if (FlxG.mouse.justPressed && FlxG.mouse.overlaps(theText))
FlxG.openURL(data.link != null ? data.link : 'https://${data.artist.toLowerCase()}.newgrounds.com');
}
}
}
3 changes: 3 additions & 0 deletions source/ui/DialogueBox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class DialogueBox extends FlxGroupExt
text.fieldWidthSet((FlxG.width / 2).floor());
*/

Ctrl.mode = Ctrl.ControlModes.TALKING;

#if ttf
text = Utils.formatText(new FlxText(0, 0, 1216), TextFormatPresets.DIALOGUE);
#else
Expand Down Expand Up @@ -155,6 +157,7 @@ class DialogueBox extends FlxGroupExt

override function kill()
{
Ctrl.mode = Ctrl.ControlModes.OVERWORLD;
options.on_complete != null ? options.on_complete() : false;
PlayState.self.dialogues.remove(this, true);
super.kill();
Expand Down
7 changes: 4 additions & 3 deletions source/ui/sheets/BaseSelectSheet.hx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BaseSelectSheet extends FlxGroupExt
description.setFormat(Paths.get('CharlieType.otf'), 32, FlxColor.BLACK, LEFT);
descGroup.add(description);

add(backTab = new FlxSpriteExt(66 + (type == COSTUME ? 500 : 0), 130, Paths.get((type == COSTUME ? 'emotetab' : 'costumetab') + '.png')));
add(backTab = new FlxSpriteExt(66 + (type == COSTUME ? 500 : 0), 130, Paths.get('${type == COSTUME ? 'emote-tab' : 'costume-tab'}.png')));

add(stickerSheetOutline = new FlxSprite(46, 219).makeGraphic(1446, 852, FlxColor.WHITE));
add(stickerSheetBase = new FlxSprite(66, 239));
Expand Down Expand Up @@ -156,11 +156,12 @@ class BaseSelectSheet extends FlxGroupExt
notSeenSprites.kill();
}

final curTab:FlxSpriteExt = new FlxSpriteExt(66 + (type == STICKER ? 500 : 0), 130, Paths.get((type == STICKER ? 'emotetab' : 'costumetab') + '.png'));
final curTab:FlxSpriteExt = new FlxSpriteExt(66 + (type == STICKER ? 500 : 0), 130,
Paths.get((type == STICKER ? 'emote-tab' : 'costume-tab') + '.png'));
curTab.scale.set(1.1, 1.1);
add(curTab);

selector = new FlxSprite().loadGraphic(Paths.get("itemnavigator.png"), true, 330, 334);
selector = new FlxSprite().loadGraphic(Paths.get("item-navigator.png"), true, 330, 334);
selector.animation.add("hover", [0, 1], 2);
add(selector);
selector.animation.play("hover");
Expand Down

0 comments on commit 072bd95

Please sign in to comment.