Merge branch 'master' of https://gitea.sustancia.synology.me/JailDoctor/thepool
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "config.h"
|
||||
#include <vector>
|
||||
#include "m_game.h"
|
||||
#include "controller.h"
|
||||
|
||||
namespace actor
|
||||
{
|
||||
@@ -682,7 +683,7 @@ namespace actor
|
||||
vec3_t max = room::getMax();
|
||||
|
||||
bool moving = false;
|
||||
if (input::keyDown(SDL_SCANCODE_LEFT) || input::keyDown(config::getKey(KEY_LEFT)))
|
||||
if (controller::down(KEY_LEFT)) // input::keyDown(SDL_SCANCODE_LEFT) || input::keyDown(config::getKey(KEY_LEFT)))
|
||||
{
|
||||
hero::useBoostRun();
|
||||
act->orient = PUSH_XN;
|
||||
@@ -702,7 +703,7 @@ namespace actor
|
||||
act->push |= PUSH_XN;
|
||||
}
|
||||
}
|
||||
else if (input::keyDown(SDL_SCANCODE_RIGHT) || input::keyDown(config::getKey(KEY_RIGHT)))
|
||||
else if (controller::down(KEY_RIGHT)) //(input::keyDown(SDL_SCANCODE_RIGHT) || input::keyDown(config::getKey(KEY_RIGHT)))
|
||||
{
|
||||
hero::useBoostRun();
|
||||
act->orient = PUSH_XP;
|
||||
@@ -722,7 +723,7 @@ namespace actor
|
||||
act->push |= PUSH_XP;
|
||||
}
|
||||
}
|
||||
else if (input::keyDown(SDL_SCANCODE_UP) || input::keyDown(config::getKey(KEY_UP)))
|
||||
else if (controller::down(KEY_UP)) //input::keyDown(SDL_SCANCODE_UP) || input::keyDown(config::getKey(KEY_UP)))
|
||||
{
|
||||
hero::useBoostRun();
|
||||
act->orient = PUSH_YN;
|
||||
@@ -742,7 +743,7 @@ namespace actor
|
||||
act->push |= PUSH_YN;
|
||||
}
|
||||
}
|
||||
else if (input::keyDown(SDL_SCANCODE_DOWN) || input::keyDown(config::getKey(KEY_DOWN)))
|
||||
else if (controller::down(KEY_DOWN)) //input::keyDown(SDL_SCANCODE_DOWN) || input::keyDown(config::getKey(KEY_DOWN)))
|
||||
{
|
||||
hero::useBoostRun();
|
||||
act->orient = PUSH_YP;
|
||||
@@ -762,7 +763,8 @@ namespace actor
|
||||
act->push |= PUSH_YP;
|
||||
}
|
||||
}
|
||||
if ((input::keyPressed(SDL_SCANCODE_RETURN) || input::keyPressed(config::getKey(KEY_PICK))) && (hero::getSkills() & SKILL_PANTS))
|
||||
//if ((input::keyPressed(SDL_SCANCODE_RETURN) || input::keyPressed(config::getKey(KEY_PICK))) && (hero::getSkills() & SKILL_PANTS))
|
||||
if ((controller::pressed(KEY_PICK)) && (hero::getSkills() & SKILL_PANTS))
|
||||
{
|
||||
if (picked)
|
||||
{
|
||||
@@ -809,7 +811,9 @@ namespace actor
|
||||
}
|
||||
}
|
||||
actor::actor_t *future_below = any_below_me(act);
|
||||
if ((input::keyDown(SDL_SCANCODE_SPACE) || input::keyDown(config::getKey(KEY_JUMP))) && (hero::getSkills() & SKILL_SHOES) && (act->pos.y + act->size.y) <= max.y && act->pos.y >= min.y && (act->pos.x + act->size.x) <= max.x && act->pos.x >= min.x && act->react_mask == 0 && ((act->pos.z == 0 && room::getFloor() != 11) || (act->below || future_below)))
|
||||
//if ((input::keyDown(SDL_SCANCODE_SPACE) || input::keyDown(config::getKey(KEY_JUMP))) &&
|
||||
if ((controller::down(KEY_JUMP)) &&
|
||||
(hero::getSkills() & SKILL_SHOES) && (act->pos.y + act->size.y) <= max.y && act->pos.y >= min.y && (act->pos.x + act->size.x) <= max.x && act->pos.x >= min.x && act->react_mask == 0 && ((act->pos.z == 0 && room::getFloor() != 11) || (act->below || future_below)))
|
||||
{
|
||||
audio::pauseChannel(walk_channel);
|
||||
audio::playSound("snd_jump.wav", SOUND_ALL);
|
||||
|
||||
@@ -59,14 +59,14 @@ namespace config
|
||||
|
||||
void definePadBtn(const int which, const int btn)
|
||||
{
|
||||
static const char* nomtecles[6] = {"btnup", "btndown", "btnleft", "btnright", "btnjump", "btnpick"};
|
||||
static const char* nombotons[6] = {"btnup", "btndown", "btnleft", "btnright", "btnjump", "btnpick"};
|
||||
pad_btns[which] = btn;
|
||||
char tmp[5];
|
||||
file::setConfigValue(nomtecles[which], SDL_itoa(btn, tmp, 10));
|
||||
file::setConfigValue(nombotons[which], SDL_itoa(btn, tmp, 10));
|
||||
}
|
||||
|
||||
const int getPadBtn(const int which)
|
||||
{
|
||||
return keys[which];
|
||||
return pad_btns[which];
|
||||
}
|
||||
}
|
||||
|
||||
16
source/controller.cpp
Normal file
16
source/controller.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "controller.h"
|
||||
#include "jinput.h"
|
||||
#include "config.h"
|
||||
|
||||
namespace controller
|
||||
{
|
||||
const bool down(const int which)
|
||||
{
|
||||
return input::keyDown(config::getKey(which)) || input::padBtnDown(config::getPadBtn(which));
|
||||
}
|
||||
|
||||
const bool pressed(const int which)
|
||||
{
|
||||
return input::keyPressed(config::getKey(which)) || input::padBtnPressed(config::getPadBtn(which));
|
||||
}
|
||||
}
|
||||
7
source/controller.h
Normal file
7
source/controller.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace controller
|
||||
{
|
||||
const bool down(const int which);
|
||||
const bool pressed(const int which);
|
||||
}
|
||||
@@ -34,6 +34,8 @@ int main(int argc, char *argv[])
|
||||
game::param_count = argc;
|
||||
game::params = argv;
|
||||
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
|
||||
input::init();
|
||||
audio::init();
|
||||
game::init();
|
||||
@@ -64,8 +66,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (e.type==SDL_CONTROLLERBUTTONDOWN) {
|
||||
input::updatePadBtn(e.cbutton.button);
|
||||
}
|
||||
if (e.type==SDL_CONTROLLERBUTTONUP) {
|
||||
input::updatePadBtnPressed(e.cbutton.button);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "m_catslife.h"
|
||||
#include "jgame.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "jdraw.h"
|
||||
#include "jaudio.h"
|
||||
#include "actor.h"
|
||||
@@ -22,7 +22,7 @@ namespace modules
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyPressed(SDL_SCANCODE_SPACE)) {
|
||||
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "m_gameover.h"
|
||||
#include "jgame.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "jdraw.h"
|
||||
#include "jaudio.h"
|
||||
#include "actor.h"
|
||||
@@ -13,7 +13,7 @@ namespace modules
|
||||
namespace gameover
|
||||
{
|
||||
actor::actor_t *heroi = nullptr;
|
||||
char time_text[7] = "000:00";
|
||||
char time_text[7] = " 00:00";
|
||||
|
||||
void init()
|
||||
{
|
||||
@@ -27,8 +27,8 @@ namespace modules
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
|
||||
time_text[0] = (minutes/100)+48;
|
||||
time_text[1] = ((minutes%100)/10)+48;
|
||||
time_text[0] = minutes<100 ? ' ' : (minutes/100)+48;
|
||||
time_text[1] = minutes<10 ? ' ' : ((minutes%100)/10)+48;
|
||||
time_text[2] = (minutes%10)+48;
|
||||
|
||||
time_text[4] = (seconds/10)+48;
|
||||
@@ -38,7 +38,7 @@ namespace modules
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyPressed(SDL_SCANCODE_SPACE)) { return false; }
|
||||
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) { return false; }
|
||||
|
||||
draw::cls(2);
|
||||
draw::color(1);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "m_ingame.h"
|
||||
#include "jgame.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "jdraw.h"
|
||||
#include "actor.h"
|
||||
#include "room.h"
|
||||
@@ -69,12 +70,11 @@ namespace modules
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||
return INGAME_CONTINUAR;
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||
if (controller::pressed(KEY_DOWN))
|
||||
selected_option = (selected_option+1)&1;
|
||||
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||
if (controller::pressed(KEY_UP))
|
||||
selected_option = (selected_option-1)&1;
|
||||
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) {
|
||||
return selected_option;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "m_logo.h"
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "jaudio.h"
|
||||
#include "config.h"
|
||||
#include <SDL2/SDL.h>
|
||||
@@ -58,11 +59,7 @@ namespace modules
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE) ||
|
||||
input::keyPressed(SDL_SCANCODE_SPACE) ||
|
||||
input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||
input::keyPressed(config::getKey(KEY_JUMP)) ||
|
||||
input::keyPressed(config::getKey(KEY_PICK)) ) {
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE) || controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "m_menu.h"
|
||||
#include "jgame.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "jdraw.h"
|
||||
#include "config.h"
|
||||
#include <SDL2/SDL.h>
|
||||
@@ -30,14 +31,13 @@ namespace modules
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||
return OPTION_EIXIR;
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||
if (controller::pressed(KEY_DOWN) || input::keyPressed(SDL_SCANCODE_DOWN))
|
||||
selected_option++; if (selected_option==5) selected_option=0;
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||
if (controller::pressed(KEY_UP) || input::keyPressed(SDL_SCANCODE_UP))
|
||||
selected_option--; if (selected_option<0) selected_option=4;
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) || input::keyPressed(SDL_SCANCODE_SPACE) ) {
|
||||
return selected_option;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,8 @@ namespace modules
|
||||
|
||||
};
|
||||
|
||||
//draw::print2(input::getPadBtnPressed(), 3, 0, 24, RED, FONT_ZOOM_NONE);
|
||||
|
||||
draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE);
|
||||
|
||||
draw::render();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "m_menu_audio.h"
|
||||
#include "jgame.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "jdraw.h"
|
||||
#include "jaudio.h"
|
||||
#include <SDL2/SDL.h>
|
||||
@@ -22,18 +23,17 @@ namespace modules
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||
return MENU_AUDIO_TORNAR;
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||
if (controller::pressed(KEY_DOWN))
|
||||
{
|
||||
selected_option = (selected_option==2)?0:selected_option+1;
|
||||
audio::playSound("snd_push.wav", SOUND_BASIC);
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||
if (controller::pressed(KEY_UP))
|
||||
{
|
||||
selected_option = (selected_option==0)?2:selected_option-1;
|
||||
audio::playSound("snd_push.wav", SOUND_BASIC);
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) {
|
||||
if (selected_option==MENU_AUDIO_MUSICA) {
|
||||
config::toggleMusic();
|
||||
if (config::isMusicEnabled())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "m_menu_gamepad.h"
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "config.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
@@ -12,12 +13,12 @@ namespace modules
|
||||
|
||||
int selected_option = MENU_GAMEPAD_AMUNT;
|
||||
states state = STATE_SELECTING;
|
||||
char name[6] = "PAD00";
|
||||
char name[7] = "BTN 00";
|
||||
|
||||
const char *getPadBtnName(const int8_t key)
|
||||
{
|
||||
name[3] = (key/10)+48;
|
||||
name[4] = (key%10)+48;
|
||||
name[4] = (key/10)+48;
|
||||
name[5] = (key%10)+48;
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -33,14 +34,13 @@ namespace modules
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||
return MENU_GAMEPAD_TORNAR;
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||
if (controller::pressed(KEY_DOWN))
|
||||
{ selected_option++; if (selected_option>6) selected_option=0; }
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||
if (controller::pressed(KEY_UP))
|
||||
{ selected_option--; if (selected_option<0) selected_option=6; }
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) {
|
||||
if (selected_option==MENU_GAMEPAD_TORNAR)
|
||||
return MENU_GAMEPAD_TORNAR;
|
||||
else
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "m_menu_tecles.h"
|
||||
#include "jdraw.h"
|
||||
#include "jinput.h"
|
||||
#include "controller.h"
|
||||
#include "config.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
@@ -42,14 +43,13 @@ namespace modules
|
||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||
return MENU_TECLES_TORNAR;
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_DOWN) || input::keyPressed(config::getKey(KEY_DOWN)))
|
||||
if (controller::pressed(KEY_DOWN) || input::keyPressed(SDL_SCANCODE_DOWN))
|
||||
{ selected_option++; if (selected_option>6) selected_option=0; }
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_UP) || input::keyPressed(config::getKey(KEY_UP)))
|
||||
if (controller::pressed(KEY_UP) || input::keyPressed(SDL_SCANCODE_UP))
|
||||
{ selected_option--; if (selected_option<0) selected_option=6; }
|
||||
|
||||
if (input::keyPressed(SDL_SCANCODE_SPACE) || input::keyPressed(SDL_SCANCODE_RETURN) ||
|
||||
input::keyPressed(config::getKey(KEY_JUMP)) || input::keyPressed(config::getKey(KEY_PICK))) {
|
||||
if (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) || input::keyPressed(SDL_SCANCODE_SPACE)) {
|
||||
if (selected_option==MENU_TECLES_TORNAR)
|
||||
return MENU_TECLES_TORNAR;
|
||||
else
|
||||
|
||||
@@ -77,7 +77,7 @@ void loadConfig()
|
||||
for (int i=0; i<6; ++i)
|
||||
{
|
||||
const int value = SDL_atoi( file::getConfigValue(nombotons[i]).c_str() );
|
||||
if (value != 0) config::defineKey(i, value);
|
||||
if (value != 0) config::definePadBtn(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user