Skip to content

Commit

Permalink
Merge pull request #62 from Renardjojo/develop
Browse files Browse the repository at this point in the history
V1.3.0
  • Loading branch information
Renardjojo authored Feb 26, 2023
2 parents 7f930ac + d50fa13 commit 1cc68b6
Show file tree
Hide file tree
Showing 25 changed files with 648 additions and 227 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(PROJECT_NAME "PetForDesktop")
set(PROJECT_VERSION 1.2.1)
set(PROJECT_VERSION 1.3.0)
set(REL_RESOURCES_DIR "content")

set(ABS_RESOURCE_DIR "${CMAKE_SOURCE_DIR}/${REL_RESOURCES_DIR}")
Expand Down
67 changes: 53 additions & 14 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
framerate: 8
sizeFactor: 2
tileCount: 14
framerate: 7
loop: true
AnimationNode:
name: sleep
sprite: sleep.png
framerate: 6
sizeFactor: 2
tileCount: 6
framerate: 4
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,9 +75,9 @@ Transitions:
to: grab
RandomDelayTransition:
from: idle1
to: [walk, jump, sleep]
duration: 3000
interval: 1000
to: [walk, walk, jump, sleep]
duration: 4000
interval: 2000
IsNotGroundedTransition:
from: idle1
to: air
Expand All @@ -61,20 +86,34 @@ Transitions:
to: grab
RandomDelayTransition:
from: idle2
to: [walk, jump, sleep]
duration: 3000
to: [walk, jump, jump, fly]
duration: 2000
interval: 1000
IsNotGroundedTransition:
from: idle2
to: air
StartLeftClicTransition:
from: walk
to: grab
TouchScreenEdgeTransition:
from: walk
to: [idle1, idle2]
RandomDelayTransition:
from: walk
to: [idle1, idle2]
duration: 3000
interval: 500
duration: 2000
interval: 1000
TouchScreenEdgeTransition:
from: fly
to: [idle1, idle2]
StartLeftClicTransition:
from: fly
to: grab
RandomDelayTransition:
from: fly
to: [idle1, idle2]
duration: 6000
interval: 2000
StartLeftClicTransition:
from: jump
to: grab
Expand All @@ -96,5 +135,5 @@ Transitions:
RandomDelayTransition:
from: sleep
to: [idle1, idle2]
duration: 9000
interval: 1000
duration: 30000
interval: 15000
21 changes: 12 additions & 9 deletions content/setting/setting.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
Game:
FPS: 60 # min 1
Scale: 4 # min 1
Scale: 2 # min 1
RandomSeed: -1 # -1: use random seed
Physic:
PhysicFrameRate: 60 # min 0
Friction: 0.85 # [0, 1] : 0 no friction, 1 max friction
GravityX: 0
GravityY: 9.81
Bounciness: 0.7 # [0, 1] : 0 no bounciness, 1 full energie restitution
ContinusCollisionMaxVelocity: 40 # min 0
FootBasasementWidth: 4 # min 2
FootBasasementHeight: 2 # min 2
Bounciness: 0.6 # [0, 1] : 0 no bounciness, 1 full energie restitution
ContinuousCollisionMaxVelocity: 40 # min 0
FootBasementWidth: 6 # min 2
FootBasementHeight: 2 # min 2
CollisionPixelRatioStopMovement: 0.3 # min 0, max 1. Ratio of pixel with collision to detect a real collision
IsGroundedDetection: 1.0 # min 0
InputReleaseImpulse: 1.0 # min 0. Velocity factor after release the pet
GamePlay:
CoyoteTimeCursorMovement: 0.05 # min 0. Record duration of the velocity before released the pet to preserve velocity with the mouse movement
Window:
ShowFrameBufferBackground: false
UseFowardWindow: true
ShowWindow: false
UseMousePassThoughWindow: true
UseForwardWindow: true # Define if the application should be displayed in forground
ShowWindow: false # Display the window edge or not
UseMousePassThoughWindow: true # Define if user can selection pet only with selected pixel or with the entire windows
Debug:
ShowEdgeDetection: false
ShowEdgeDetection: false # Debug mode to display the result of the collision alogyrthm on the entire window
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.

104 changes: 104 additions & 0 deletions include/Engine/Monitors.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#pragma once

#include "Engine/Vector2.hpp"

#include <GLFW/glfw3.h>

#include <vector>

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]);
}
}

void getMainMonitorWorkingArea(Vec2i& position, Vec2i& size) const
{
getMonitorPosition(0, position);
getMonitorSize(0, size);
}

Vec2i getMonitorsSize() const
{
Vec2i size = Vec2i::zero();
const GLFWvidmode* currentVideoMode;
for (int i = 0; i < monitors.size(); i++)
{
currentVideoMode = glfwGetVideoMode(monitors[i]);
size.x += currentVideoMode->width;
size.y += currentVideoMode->height;
}
return size;
}

void getMonitorPosition(int index, Vec2i& position) const
{
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
{
Vec2i sizeMM = Vec2i::zero();
int width_mm, height_mm;
for (int i = 0; i < monitors.size(); i++)
{
glfwGetMonitorPhysicalSize(monitors[i], &width_mm, &height_mm);
sizeMM.x += width_mm;
sizeMM.y += height_mm;
}
return sizeMM;
}

void addMonitor(GLFWmonitor* monitor)
{
monitors.emplace_back(monitor);
}

void removeMonitor(const GLFWmonitor* monitor)
{
for (int i = 0; i < monitors.size(); ++i)
{
if (monitors[i] == monitor)
{
monitors.erase(monitors.begin() + i);
break;
}
}
}

int getMonitorsCount() const
{
return monitors.size();
}
};
Loading

0 comments on commit 1cc68b6

Please sign in to comment.