Skip to content

Commit

Permalink
Merge pull request #60 from Renardjojo/feature/fly
Browse files Browse the repository at this point in the history
Add ability to fly
  • Loading branch information
Renardjojo authored Feb 24, 2023
2 parents 850664b + 65d3a32 commit 6ad7d1b
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 100 deletions.
49 changes: 44 additions & 5 deletions content/setting/animation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,70 @@ Nodes:
AnimationNode:
name: idle1
sprite: idle.png
sizeFactor: 2
tileCount: 5
framerate: 5
loop: true
AnimationNode:
name: idle2
sprite: idle2.png
sizeFactor: 2
tileCount: 14
framerate: 8
loop: true
AnimationNode:
name: sleep
sprite: sleep.png
sizeFactor: 2
tileCount: 6
framerate: 6
loop: true
GrabNode:
name: grab
sprite: grab.png
sizeFactor: 2
tileCount: 4
framerate: 10
loop: true
PetWalkNode:
MovementDirectionNode:
name: walk
sprite: walk.png
sizeFactor: 2
tileCount: 8
framerate: 10
direction: [1, 0]
thrust: 0.2
directions: [[0.2, 0], [-0.2, 0]]
applyGravity: true
loop: true
MovementDirectionNode:
name: fly
sprite: flyBubble.png
sizeFactor: 1
tileCount: 1
framerate: 10
directions: [[0.15, -0.1], [0.1, -0.1], [-0.1, -0.1], [-0.15, -0.1]]
applyGravity: false
loop: true
PetJumpNode:
name: jump
sprite: jump.png
sizeFactor: 2
tileCount: 4
framerate: 10
direction: [1, 0]
verticalThrust: 0.15
horizontalThrust: 0.3
AnimationNode:
name: air
sprite: air.png
sizeFactor: 2
tileCount: 1
framerate: 10
loop: true
AnimationNode:
name: landing
sprite: landing.png
sizeFactor: 2
tileCount: 6
framerate: 10
loop: false
Transitions:
Expand All @@ -50,7 +75,7 @@ Transitions:
to: grab
RandomDelayTransition:
from: idle1
to: [walk, jump, sleep]
to: [walk, jump, sleep, fly]
duration: 3000
interval: 1000
IsNotGroundedTransition:
Expand All @@ -61,7 +86,7 @@ Transitions:
to: grab
RandomDelayTransition:
from: idle2
to: [walk, jump, sleep]
to: [walk, jump, sleep, fly]
duration: 3000
interval: 1000
IsNotGroundedTransition:
Expand All @@ -70,11 +95,25 @@ Transitions:
StartLeftClicTransition:
from: walk
to: grab
TouchScreenEdgeTransition:
from: walk
to: [idle1, idle2]
RandomDelayTransition:
from: walk
to: [idle1, idle2]
duration: 3000
interval: 500
TouchScreenEdgeTransition:
from: fly
to: [idle1, idle2]
StartLeftClicTransition:
from: fly
to: grab
RandomDelayTransition:
from: fly
to: [idle1, idle2]
duration: 5000
interval: 1000
StartLeftClicTransition:
from: jump
to: grab
Expand Down
2 changes: 1 addition & 1 deletion content/setting/setting.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Game:
FPS: 60 # min 1
Scale: 4 # min 1
Scale: 2 # min 1
RandomSeed: -1 # -1: use random seed
Physic:
PhysicFrameRate: 60 # min 0
Expand Down
3 changes: 3 additions & 0 deletions content/sprites/flyBubble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions content/sprites/jumpAir.png

This file was deleted.

3 changes: 0 additions & 3 deletions content/sprites/jumpEnd.png

This file was deleted.

3 changes: 0 additions & 3 deletions content/sprites/startJump.png

This file was deleted.

32 changes: 24 additions & 8 deletions include/Engine/Monitors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,34 @@ class Monitors
protected:
std::vector<GLFWmonitor*> monitors;

private:
static Monitors* s_instances;

public:
static Monitors& getInstance()
{
return *s_instances;
}

public:
void init()
{
s_instances = this;

int monitorCount;
GLFWmonitor** pMonitors = glfwGetMonitors(&monitorCount);
monitors.reserve(monitorCount);

for (int i = 0; i < monitorCount; ++i)
{
addMonitor(pMonitors[i]);
glfwSetMonitorUserPointer(pMonitors[i], this);
}
}

void getMainMonitorWorkingArea(Vec2i& position, Vec2i& size) const
{
glfwGetMonitorWorkarea(glfwGetPrimaryMonitor(), &position.x, &position.y, &size.x, &size.y);
getMonitorPosition(0, position);
getMonitorSize(0, size);
}

Vec2i getMonitorsSize() const
Expand All @@ -39,16 +50,21 @@ class Monitors
currentVideoMode = glfwGetVideoMode(monitors[i]);
size.x += currentVideoMode->width;
size.y += currentVideoMode->height;

int xpos, ypos, width, height;
glfwGetMonitorWorkarea(monitors[i], &xpos, &ypos, &width, &height);
}
return size;
}

void getMonitorWorkingArea(int index, Vec2i& position, Vec2i& size) const
void getMonitorPosition(int index, Vec2i& position) const
{
glfwGetMonitorWorkarea(monitors[index], &position.x, &position.y, &size.x, &size.y);
glfwGetMonitorPos(monitors[index], &position.x, &position.y);
}

void getMonitorSize(int index, Vec2i& size) const
{
const GLFWvidmode* currentVideoMode;
currentVideoMode = glfwGetVideoMode(monitors[index]);
size.x = currentVideoMode->width;
size.y = currentVideoMode->height;
}

Vec2i getMonitorPhysicalSize() const
Expand Down
Loading

0 comments on commit 6ad7d1b

Please sign in to comment.