Skip to content

Commit

Permalink
Merge branch 'pr/15'
Browse files Browse the repository at this point in the history
  • Loading branch information
chosencharacters committed Nov 30, 2024
2 parents 5f9cc62 + 3c96269 commit 00d62fe
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 110 deletions.
6 changes: 3 additions & 3 deletions assets/data/levels/TankmasLand.ldtk
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
"maxWidth": null,
"minHeight": 64,
"maxHeight": null,
"keepAspectRatio": false,
"keepAspectRatio": true,
"tileOpacity": 1,
"fillOpacity": 1,
"lineOpacity": 1,
Expand All @@ -656,8 +656,8 @@
"maxCount": 0,
"limitScope": "PerLevel",
"limitBehavior": "MoveLastOne",
"pivotX": 0,
"pivotY": 0,
"pivotX": 0.5,
"pivotY": 0.5,
"fieldDefs": [
{
"identifier": "ActivityType",
Expand Down
30 changes: 23 additions & 7 deletions assets/data/levels/TankmasLand/hotel_courtyard.ldtkl
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,37 @@
{ "px": [0,2144], "src": [32,0], "f": 0, "t": 1, "d": [6901], "a": 1 },
{ "px": [3264,2144], "src": [32,0], "f": 0, "t": 1, "d": [7003], "a": 1 },
{ "px": [0,2176], "src": [32,0], "f": 0, "t": 1, "d": [7004], "a": 1 },
{ "px": [1664,2176], "src": [0,0], "f": 0, "t": 0, "d": [7056], "a": 1 },
{ "px": [3264,2176], "src": [32,0], "f": 0, "t": 1, "d": [7106], "a": 1 },
{ "px": [0,2208], "src": [32,0], "f": 0, "t": 1, "d": [7107], "a": 1 },
{ "px": [1664,2208], "src": [0,0], "f": 0, "t": 0, "d": [7159], "a": 1 },
{ "px": [1696,2208], "src": [0,0], "f": 0, "t": 0, "d": [7160], "a": 1 },
{ "px": [2112,2208], "src": [0,0], "f": 0, "t": 0, "d": [7173], "a": 1 },
{ "px": [2144,2208], "src": [0,0], "f": 0, "t": 0, "d": [7174], "a": 1 },
{ "px": [2176,2208], "src": [0,0], "f": 0, "t": 0, "d": [7175], "a": 1 },
{ "px": [3264,2208], "src": [32,0], "f": 0, "t": 1, "d": [7209], "a": 1 },
{ "px": [0,2240], "src": [32,0], "f": 0, "t": 1, "d": [7210], "a": 1 },
{ "px": [1696,2240], "src": [0,0], "f": 0, "t": 0, "d": [7263], "a": 1 },
{ "px": [1728,2240], "src": [0,0], "f": 0, "t": 0, "d": [7264], "a": 1 },
{ "px": [2176,2240], "src": [0,0], "f": 0, "t": 0, "d": [7278], "a": 1 },
{ "px": [2208,2240], "src": [0,0], "f": 0, "t": 0, "d": [7279], "a": 1 },
{ "px": [2240,2240], "src": [0,0], "f": 0, "t": 0, "d": [7280], "a": 1 },
{ "px": [0,2272], "src": [32,0], "f": 0, "t": 1, "d": [7313], "a": 1 },
{ "px": [1728,2272], "src": [0,0], "f": 0, "t": 0, "d": [7367], "a": 1 },
{ "px": [1760,2272], "src": [0,0], "f": 0, "t": 0, "d": [7368], "a": 1 },
{ "px": [0,2304], "src": [32,0], "f": 0, "t": 1, "d": [7416], "a": 1 },
{ "px": [1760,2304], "src": [0,0], "f": 0, "t": 0, "d": [7471], "a": 1 },
{ "px": [1792,2304], "src": [0,0], "f": 0, "t": 0, "d": [7472], "a": 1 },
{ "px": [1824,2304], "src": [0,0], "f": 0, "t": 0, "d": [7473], "a": 1 },
{ "px": [0,2336], "src": [32,0], "f": 0, "t": 1, "d": [7519], "a": 1 },
{ "px": [1824,2336], "src": [0,0], "f": 0, "t": 0, "d": [7576], "a": 1 },
{ "px": [1856,2336], "src": [0,0], "f": 0, "t": 0, "d": [7577], "a": 1 },
{ "px": [0,2368], "src": [32,0], "f": 0, "t": 1, "d": [7622], "a": 1 },
{ "px": [1856,2368], "src": [0,0], "f": 0, "t": 0, "d": [7680], "a": 1 },
{ "px": [1888,2368], "src": [0,0], "f": 0, "t": 0, "d": [7681], "a": 1 },
{ "px": [0,2400], "src": [32,0], "f": 0, "t": 1, "d": [7725], "a": 1 },
{ "px": [1888,2400], "src": [0,0], "f": 0, "t": 0, "d": [7784], "a": 1 },
{ "px": [1920,2400], "src": [0,0], "f": 0, "t": 0, "d": [7785], "a": 1 },
{ "px": [0,2432], "src": [32,0], "f": 0, "t": 1, "d": [7828], "a": 1 },
{ "px": [0,2464], "src": [32,0], "f": 0, "t": 1, "d": [7931], "a": 1 },
{ "px": [0,2496], "src": [32,0], "f": 0, "t": 1, "d": [8034], "a": 1 },
Expand Down Expand Up @@ -587,22 +603,22 @@
},
{
"__identifier": "Activity_Area",
"__grid": [76,128],
"__pivot": [0,0],
"__grid": [103,154],
"__pivot": [0.5,0.5],
"__tags": [],
"__tile": null,
"__smartColor": "#484BFF",
"iid": "d04eb910-9b00-11ef-a438-bf6fb7c2c1d9",
"width": 960,
"height": 832,
"width": 880,
"height": 880,
"defUid": 24,
"px": [1216,2048],
"px": [1648,2464],
"fieldInstances": [{ "__identifier": "ActivityType", "__type": "LocalEnum.ActivityType", "__value": "Bonfire", "__tile": null, "defUid": 26, "realEditorValues": [{
"id": "V_String",
"params": ["Bonfire"]
}] }],
"__worldX": 1248,
"__worldY": 2064
"__worldX": 1680,
"__worldY": 2480
}
]
},
Expand Down
Empty file added assets/videos/videos-here.txt
Empty file.
28 changes: 20 additions & 8 deletions source/entities/Interactable.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ package entities;
import entities.base.NGSprite;

class Interactable extends NGSprite
{
public var detect_range:Int;
{
public var detect_range:Int;
public var interactable:Bool;

public var marked(default, set):Bool = false;

function set_marked(m)
{
if (m != marked)
mark_target(m);
return marked = m;
}

public function new(?X:Float, ?Y:Float)
{
super(X, Y);
Expand All @@ -33,12 +42,15 @@ class Interactable extends NGSprite
return null;
}

public function mark_target(mark:Bool)
throw "not implemented";
// Called when in range and player presses interact button
public function on_interact() {}

function mark_target(mark:Bool) {}

public static function unmark_all<T:Interactable>(interactables:FlxTypedGroup<T>)
for (interactable in interactables)
interactable.marked = false;

public static function unmark_all<T:Interactable>(interactables:FlxTypedGroup<T>)
for (interactable in interactables)
interactable.mark_target(false);
override function kill()
{
PlayState.self.interactables.remove(this, true);
Expand All @@ -51,4 +63,4 @@ enum abstract InteractableType(String) from String to String
final NPC = "npc";
final PRESENT = "present";
final MINIGAME = "minigame";
}
}
15 changes: 3 additions & 12 deletions source/entities/Minigame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,9 @@ class Minigame extends Interactable
alpha = 0.5;
}

public override function mark_target(mark:Bool)
override function on_interact()
{
if (mark)
{
if (Ctrl.jjump[1])
{
start_minigame();
}
}
else
{
}
start_minigame();
}

function start_minigame()
Expand All @@ -47,4 +38,4 @@ class Minigame extends Interactable

MinigameHandler.instance.playMinigame(minigame_id);
}
}
}
14 changes: 9 additions & 5 deletions source/entities/NPC.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class NPC extends Interactable

public function new(?X:Float, ?Y:Float, name:String)
{
super(X, Y);
super(X, Y);

detect_range = 300;
interactable = true;

type = Interactable.InteractableType.NPC;

this.name = name;

PlayState.self.npcs.add(this);
PlayState.self.npcs.add(this);

loadGraphic(Paths.get('${name}.png'));

Expand All @@ -40,12 +40,16 @@ class NPC extends Interactable
sprite_anim.anim(PresentAnimation.IDLE);
case NEARBY:
sprite_anim.anim(PresentAnimation.NEARBY);
if (Ctrl.jjump[1])
start_chat();
case CHATTING:
sprite_anim.anim(PresentAnimation.IDLE);
}

override function on_interact()
{
if (state == NEARBY)
start_chat();
}

function start_chat()
{
Ctrl.allFalse();
Expand Down
34 changes: 22 additions & 12 deletions source/entities/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import entities.Interactable;
import entities.base.BaseUser;
import net.tankmas.NetDefs.NetUserDef;
import net.tankmas.OnlineLoop;

class Player extends BaseUser
{
var move_no_input_drag:Float = 0.9;
Expand Down Expand Up @@ -61,7 +62,7 @@ class Player extends BaseUser

override function update(elapsed:Float)
{
if (Main.DEV && Ctrl.any(Ctrl.jaction))
if (Main.DEV && Ctrl.any(Ctrl.jaction) && !interact_in_use())
debug_rotate_costumes();

fsm();
Expand Down Expand Up @@ -125,13 +126,21 @@ class Player extends BaseUser
{
if (active_activity_area == null)
return;
if (Ctrl.jjump[1])
if (Ctrl.jaction[1])
{
active_activity_area.on_interact(this);
}
}

var previously_closest_interactable:Interactable;
var active_interactable:Interactable;

// returns true if either in an activity area, or if close to an interactable.
// If false, the use button can be used for other stuff
public function interact_in_use()
{
return active_activity_area != null || (active_interactable != null && active_interactable.interactable);
}

function detect_interactables()
{
// Disable interactions if in activity area
Expand All @@ -142,16 +151,16 @@ class Player extends BaseUser
}

var closest:Interactable = Interactable.find_closest_in_array(this, Interactable.find_in_detect_range(this, PlayState.self.interactables));
var target_changed = closest != previously_closest_interactable;
var target_changed = closest != active_interactable;

if (target_changed && previously_closest_interactable != null)
if (target_changed && active_interactable != null)
{
previously_closest_interactable.mark_target(false);
active_interactable.marked = false;
}

if (closest == null)
{
previously_closest_interactable = null;
active_interactable = null;
return;
}

Expand All @@ -165,19 +174,21 @@ class Player extends BaseUser
// nothin
}

if (target_changed)
closest.marked = true;
active_interactable = closest;

if (Ctrl.jaction[1])
{
closest.mark_target(true);
active_interactable.on_interact();
}

previously_closest_interactable = closest;
}

override function kill()
{
PlayState.self.player = null;
super.kill();
}

override function use_sticker(sticker_name:String):Bool
{
var sticker_got_used:Bool = super.use_sticker(sticker_name);
Expand All @@ -202,7 +213,6 @@ class Player extends BaseUser
if (last_update_json.y != y.floor() || force_send_full_user)
def.y = y.floor();


if (last_update_json.costume != costume.name || force_send_full_user)
def.costume = costume.name;

Expand Down
Loading

0 comments on commit 00d62fe

Please sign in to comment.