Skip to content

Commit

Permalink
Merge branch 'pr/10'
Browse files Browse the repository at this point in the history
  • Loading branch information
chosencharacters committed Nov 29, 2024
2 parents 9d92d0c + 875e6f6 commit 5e1d91e
Show file tree
Hide file tree
Showing 28 changed files with 821 additions and 16 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ data/events/requests-log.json
data/events/events.json

# Installed libraries
.haxelib/
.haxelib
server

ldtkbackups
*.png~
57 changes: 57 additions & 0 deletions achievements.cdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"sheets": [
{
"name": "achievements",
"columns": [
{
"typeStr": "0",
"name": "Id"
},
{
"typeStr": "1",
"name": "Name",
"display": null
},
{
"typeStr": "1",
"name": "Description",
"display": null
},
{
"typeStr": "7",
"name": "Picture",
"opt": true,
"display": null
},
{
"typeStr": "1",
"name": "steamID",
"opt": true
},
{
"typeStr": "1",
"name": "xboxID",
"opt": true
},
{
"typeStr": "1",
"name": "psID",
"display": null
}
],
"lines": [
{
"Name": "test",
"psID": "qsd",
"steamID": "sd",
"xboxID": "sd",
"Id": "test"
}
],
"separators": [],
"props": {}
}
],
"customTypes": [],
"compress": false
}
Binary file added assets/images/bonfire/grill_stick.aseprite
Binary file not shown.
28 changes: 28 additions & 0 deletions assets/images/bonfire/grill_stick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ "frames": {
"grill_stick.aseprite": {
"frame": { "x": 0, "y": 0, "w": 128, "h": 128 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
"sourceSize": { "w": 128, "h": 128 },
"duration": 100
}
},
"meta": {
"app": "https://www.aseprite.org/",
"version": "1.3.10.1-x64",
"image": "grill_stick.png",
"format": "RGBA8888",
"size": { "w": 128, "h": 128 },
"scale": "1",
"frameTags": [
{ "name": "idle", "from": 0, "to": 0, "direction": "forward", "color": "#000000ff" }
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" },
{ "name": "Layer 2", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}
Binary file added assets/images/bonfire/grill_stick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/bonfire/marshmallow.aseprite
Binary file not shown.
74 changes: 74 additions & 0 deletions assets/images/bonfire/marshmallow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{ "frames": {
"marshmallow 0.aseprite": {
"frame": { "x": 0, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
"sourceSize": { "w": 64, "h": 64 },
"duration": 100
},
"marshmallow 1.aseprite": {
"frame": { "x": 64, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
"sourceSize": { "w": 64, "h": 64 },
"duration": 100
},
"marshmallow 2.aseprite": {
"frame": { "x": 128, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
"sourceSize": { "w": 64, "h": 64 },
"duration": 100
},
"marshmallow 3.aseprite": {
"frame": { "x": 192, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
"sourceSize": { "w": 64, "h": 64 },
"duration": 100
},
"marshmallow 4.aseprite": {
"frame": { "x": 256, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
"sourceSize": { "w": 64, "h": 64 },
"duration": 100
},
"marshmallow 5.aseprite": {
"frame": { "x": 320, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
"sourceSize": { "w": 64, "h": 64 },
"duration": 100
},
"marshmallow 6.aseprite": {
"frame": { "x": 384, "y": 0, "w": 64, "h": 64 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
"sourceSize": { "w": 64, "h": 64 },
"duration": 100
}
},
"meta": {
"app": "https://www.aseprite.org/",
"version": "1.3.10.1-x64",
"image": "marshmallow.png",
"format": "RGBA8888",
"size": { "w": 448, "h": 64 },
"scale": "1",
"frameTags": [
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}
Binary file added assets/images/bonfire/marshmallow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sounds/bonfire/burned_marshmallow.wav
Binary file not shown.
Binary file added assets/sounds/bonfire/grill_1.wav
Binary file not shown.
Binary file added assets/sounds/bonfire/grill_2.wav
Binary file not shown.
Binary file added assets/sounds/bonfire/grill_3.wav
Binary file not shown.
Binary file added assets/sounds/bonfire/grill_4.wav
Binary file not shown.
Binary file added assets/sounds/bonfire/grill_5.wav
Binary file not shown.
2 changes: 1 addition & 1 deletion source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import utils.CrashHandler;

class Main extends Sprite
{
public static var username:String = #if random_username data.Uuid.v4() #else "not_very_squidly" #end;
public static var username:String = #if random_username 'poop_${Math.random()}' #else "not_very_squidly" #end;

public static var current_room_id:String = "1";

Expand Down
112 changes: 112 additions & 0 deletions source/activities/ActivityArea.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package activities;

import activities.ActivityAreaInstance;
import activities.bonfire.BonfireArea;
import entities.Player;
import entities.base.BaseUser;
import haxe.Constraints;
import levels.LDTKLevel;
import levels.TankmasLevel;
import net.tankmas.NetDefs.NetEventDef;

typedef ActivityType = levels.LdtkProject.Enum_ActivityType;

enum AreaShape
{
Circle;
Rectangle;
}

class ActivityArea extends FlxSprite
{
var active_players:Map<String, ActivityAreaInstance> = new Map();
var activity_type:ActivityType;
var shape:AreaShape;

public function new(type:ActivityType, X, Y, w, h, shape = AreaShape.Circle)
{
super(X, Y);
this.activity_type = type;
height = h;
width = w;
this.shape = shape;
PlayState.self.activity_areas.add(this);
}

public function in_area(x:Float, y:Float)
{
switch (shape)
{
case Circle:
var dx = x - this.x;
var dy = y - this.y;
var r = width * 0.5;
var rr = r * r;
var dist_sq = dx * dx + dy * dy;
return dist_sq < rr;
case Rectangle:
if (x < this.x)
return false;
if (y < this.y)
return false;
if (x > this.x + width)
return false;
if (y > this.y + height)
return false;
return true;
}
return false;
}

function create_instance(player:BaseUser)
{
switch (activity_type)
{
case Bonfire:
return new BonfireArea(player, this);
}
}

public function on_enter(player:BaseUser)
{
if (active_players[player.username] != null)
return;

var area = create_instance(player);

active_players[player.username] = area;
}

public function on_leave(player:BaseUser)
{
var area = active_players[player.username];
if (area == null)
return;

area.on_leave();
active_players[player.username] = null;
}

public function on_event(event:NetEventDef, player:BaseUser)
{
var area = active_players[player.username];
if (area == null)
return;
area.on_event(event);
}

// Happens when the local player presses the interact button
public function on_interact(player:Player)
{
var area = active_players[player.username];
if (area == null)
return;
area.on_interact();
}

override function kill()
{
PlayState.self.activity_areas.remove(this, true);
super.kill();
}
}
23 changes: 23 additions & 0 deletions source/activities/ActivityAreaInstance.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package activities;

import entities.base.BaseUser;
import net.tankmas.NetDefs.NetEventDef;

class ActivityAreaInstance extends FlxSprite
{
var player:BaseUser;
var activity_area:ActivityArea;

public function new(player:BaseUser, activity_area:ActivityArea)
{
super(activity_area.x, activity_area.y);
this.player = player;
this.activity_area = activity_area;
}

public function on_leave() {}

public function on_interact() {}

public function on_event(event:NetEventDef) {}
}
45 changes: 45 additions & 0 deletions source/activities/bonfire/BonfireArea.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package activities.bonfire;

import entities.base.BaseUser;
import net.tankmas.NetDefs.NetEventDef;
import net.tankmas.NetDefs.NetEventType;
import net.tankmas.OnlineLoop;

class BonfireArea extends ActivityAreaInstance
{
var stick: BonfireStick;
var local: Bool;
public function new(player:BaseUser, area:ActivityArea)
{
super(player, area);
local = player == PlayState.self.player;
stick = new BonfireStick(player, this);
stick.activate();
}

override function on_leave() {
super.on_leave();
stick.hide();
destroy();
}

override function on_interact() {
var marshmallow = stick.marshmallow;
if (marshmallow != null) {
OnlineLoop.post_marshmallow_discard(Main.current_room_id, marshmallow.current_level);
}
stick.shake_off();
}

override function on_event(event:NetEventDef) {
super.on_event(event);
if (local) return;
if (event.type == NetEventType.DROP_MARSHMALLOW) {
var level: Int = cast(event.data.level, Int);
if (stick.marshmallow != null) {
stick.marshmallow.set_level(level);
}
stick.shake_off();
}
}
}
Loading

0 comments on commit 5e1d91e

Please sign in to comment.