Compare commits
19 Commits
fd94aea99b
...
v2.0
| Author | SHA1 | Date | |
|---|---|---|---|
| d3f17bc93a | |||
| b7490ed1c1 | |||
| 836deb720d | |||
| 7e9a1cb049 | |||
| f928195a05 | |||
| 84b09a4987 | |||
| f0b9a1d134 | |||
| 64369921ec | |||
| 70ae7f67a9 | |||
| 2ea86ef39f | |||
| 658bb71441 | |||
| 0b996ea321 | |||
| cf072424c6 | |||
| 42c0f19c68 | |||
| 8d1cabb288 | |||
| 87aeaab6b8 | |||
| ad5fb0fc22 | |||
| 8e6d546b97 | |||
| f916381a9b |
@@ -3,7 +3,7 @@
|
||||
# box height
|
||||
10
|
||||
# 32 espacio ( )
|
||||
7
|
||||
5
|
||||
# 33 !
|
||||
4
|
||||
# 34 "
|
||||
|
||||
BIN
media/font/nokia2.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
194
media/font/nokia2.txt
Normal file
@@ -0,0 +1,194 @@
|
||||
# box width
|
||||
10
|
||||
# box height
|
||||
10
|
||||
# 32 espacio ( )
|
||||
5
|
||||
# 33 !
|
||||
4
|
||||
# 34 "
|
||||
5
|
||||
# 35 #
|
||||
7
|
||||
# 36 $
|
||||
7
|
||||
# 37 %
|
||||
8
|
||||
# 38 &
|
||||
8
|
||||
# 39 '
|
||||
3
|
||||
# 40 (
|
||||
5
|
||||
# 41 )
|
||||
5
|
||||
# 42 *
|
||||
7
|
||||
# 43 +
|
||||
7
|
||||
# 44 ,
|
||||
4
|
||||
# 45 -
|
||||
6
|
||||
# 46 .
|
||||
4
|
||||
# 47 /
|
||||
5
|
||||
# 48 0
|
||||
7
|
||||
# 49 1
|
||||
5
|
||||
# 50 2
|
||||
7
|
||||
# 51 3
|
||||
7
|
||||
# 52 4
|
||||
7
|
||||
# 53 5
|
||||
7
|
||||
# 54 6
|
||||
7
|
||||
# 55 7
|
||||
7
|
||||
# 56 8
|
||||
7
|
||||
# 57 9
|
||||
7
|
||||
# 58 :
|
||||
4
|
||||
# 59 ;
|
||||
4
|
||||
# 60 <
|
||||
6
|
||||
# 61 =
|
||||
6
|
||||
# 62 >
|
||||
6
|
||||
# 63 ?
|
||||
7
|
||||
# 64 @
|
||||
8
|
||||
# 65 A
|
||||
7
|
||||
# 66 B
|
||||
7
|
||||
# 67 C
|
||||
7
|
||||
# 68 D
|
||||
7
|
||||
# 69 E
|
||||
7
|
||||
# 70 F
|
||||
7
|
||||
# 71 G
|
||||
7
|
||||
# 72 H
|
||||
7
|
||||
# 73 I
|
||||
4
|
||||
# 74 J
|
||||
6
|
||||
# 75 K
|
||||
8
|
||||
# 76 L
|
||||
6
|
||||
# 77 M
|
||||
9
|
||||
# 78 N
|
||||
8
|
||||
# 79 O
|
||||
8
|
||||
# 80 P
|
||||
7
|
||||
# 81 Q
|
||||
8
|
||||
# 82 R
|
||||
7
|
||||
# 83 S
|
||||
6
|
||||
# 84 T
|
||||
8
|
||||
# 85 U
|
||||
7
|
||||
# 86 V
|
||||
8
|
||||
# 87 W
|
||||
9
|
||||
# 88 X
|
||||
8
|
||||
# 89 Y
|
||||
8
|
||||
# 90 Z
|
||||
7
|
||||
# 91 [
|
||||
4
|
||||
# 92 \
|
||||
5
|
||||
# 93 ]
|
||||
4
|
||||
# 94 ^
|
||||
5
|
||||
# 95 _
|
||||
8
|
||||
# 96 `
|
||||
4
|
||||
# 97 a
|
||||
7
|
||||
# 98 b
|
||||
7
|
||||
# 99 c
|
||||
6
|
||||
# 100 d
|
||||
7
|
||||
# 101 e
|
||||
7
|
||||
# 102 f
|
||||
5
|
||||
# 103 g
|
||||
7
|
||||
# 104 h
|
||||
7
|
||||
# 105 i
|
||||
4
|
||||
# 106 j
|
||||
5
|
||||
# 107 k
|
||||
7
|
||||
# 108 l
|
||||
4
|
||||
# 109 m
|
||||
10
|
||||
# 110 n
|
||||
7
|
||||
# 111 o
|
||||
7
|
||||
# 112 p
|
||||
7
|
||||
# 113 q
|
||||
7
|
||||
# 114 r
|
||||
6
|
||||
# 115 s
|
||||
6
|
||||
# 116 t
|
||||
5
|
||||
# 117 u
|
||||
7
|
||||
# 118 v
|
||||
7
|
||||
# 119 w
|
||||
9
|
||||
# 120 x
|
||||
7
|
||||
# 121 y
|
||||
7
|
||||
# 122 z
|
||||
7
|
||||
# 123 { -> ñ
|
||||
7
|
||||
# 124 | -> ç
|
||||
7
|
||||
# 125 }
|
||||
0
|
||||
# 126 ~
|
||||
0
|
||||
|
Before Width: | Height: | Size: 3.8 KiB |
BIN
media/font/nokia_big2.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
@@ -3,7 +3,7 @@
|
||||
# box height
|
||||
20
|
||||
# 32 espacio ( )
|
||||
14
|
||||
8
|
||||
# 33 !
|
||||
8
|
||||
# 34 "
|
||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 773 B After Width: | Height: | Size: 654 B |
@@ -75,7 +75,7 @@ Temps detes:
|
||||
## 37 - TEXTOS DEL JUEGO
|
||||
D E M O
|
||||
## 38 - TEXTOS DEL JUEGO
|
||||
PANTALLA
|
||||
Pantalla
|
||||
## 39 - MARCADOR
|
||||
PUNTS
|
||||
## 40 - MARCADOR
|
||||
@@ -99,7 +99,7 @@ SI
|
||||
## 49 - MENU GAME OVER
|
||||
NO
|
||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||
FELICITATS!!
|
||||
Felicitats!!
|
||||
## 51 - MENU DEL TITULO
|
||||
1 JUGADOR
|
||||
## 52 - MENU DEL TITULO
|
||||
@@ -113,7 +113,7 @@ mult
|
||||
## 56 MARCADOR
|
||||
max. puntuacio
|
||||
## 57 MARCADOR
|
||||
nivell
|
||||
pantalla
|
||||
## 58 - MENU DE OPCIONES
|
||||
MODE DE VISUALITZACIO
|
||||
## 59 - MENU DE OPCIONES
|
||||
@@ -148,7 +148,11 @@ NEAREST
|
||||
ACTIVADA
|
||||
## 74 - MENU DE OPCIONES
|
||||
DESACTIVADA
|
||||
## 75 - MENU DE OPCIONES
|
||||
ENDAVANT!
|
||||
## 75 - JUEGO
|
||||
Endavant!
|
||||
## 76 - JUEGO
|
||||
1.000.000 DE PUNTS!
|
||||
1.000.000 de punts!
|
||||
## 77 - PANTALLA DE GAME OVER
|
||||
PUNTS J1:
|
||||
## 78 - PANTALLA DE GAME OVER
|
||||
PUNTS J2:
|
||||
@@ -71,11 +71,11 @@ FUCKING MACHINE!
|
||||
## 35 - INTRO
|
||||
Blop... blop... blop...
|
||||
## 36 - TEXTOS DEL JUEGO
|
||||
Time Stopped:
|
||||
Time stopped:
|
||||
## 37 - TEXTOS DEL JUEGO
|
||||
D E M O
|
||||
## 38 - TEXTOS DEL JUEGO
|
||||
STAGE
|
||||
Stage
|
||||
## 39 - MARCADOR
|
||||
SCORE
|
||||
## 40 - MARCADOR
|
||||
@@ -99,7 +99,7 @@ YES
|
||||
## 49 - MENU GAME OVER
|
||||
NO
|
||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||
NICE!!
|
||||
Congratulations!!
|
||||
## 51 - MENU DEL TITULO
|
||||
1 PLAYER
|
||||
## 52 - MENU DEL TITULO
|
||||
@@ -149,6 +149,10 @@ ON
|
||||
## 74 - MENU DE OPCIONES
|
||||
OFF
|
||||
## 75 - JUEGO
|
||||
GET READY!
|
||||
Get Ready!
|
||||
## 76 - JUEGO
|
||||
1.000.000 POINTS!
|
||||
1.000.000 points!
|
||||
## 77 - PANTALLA DE GAME OVER
|
||||
PLAYER1 SCORE:
|
||||
## 78 - PANTALLA DE GAME OVER
|
||||
PLAYER2 SCORE:
|
||||
@@ -75,7 +75,7 @@ Tiempo:
|
||||
## 37 - TEXTOS DEL JUEGO
|
||||
D E M O
|
||||
## 38 - TEXTOS DEL JUEGO
|
||||
FASE
|
||||
Fase
|
||||
## 39 - MARCADOR
|
||||
PUNTOS
|
||||
## 40 - MARCADOR
|
||||
@@ -99,7 +99,7 @@ SI
|
||||
## 49 - MENU GAME OVER
|
||||
NO
|
||||
## 50 - TEXTO DE COMPLETAR EL JUEGO
|
||||
FELICIDADES!!
|
||||
Felicidades!!
|
||||
## 51 - MENU DEL TITULO
|
||||
1 JUGADOR
|
||||
## 52 - MENU DEL TITULO
|
||||
@@ -148,7 +148,11 @@ NEAREST
|
||||
ACTIVADA
|
||||
## 74 - MENU DE OPCIONES
|
||||
DESACTIVADA
|
||||
## 75 - MENU DE OPCIONES
|
||||
ADELANTE!
|
||||
## 75 - JUEGO
|
||||
Adelante!
|
||||
## 76 - JUEGO
|
||||
1.000.000 DE PUNTOS!
|
||||
1.000.000 de puntos!
|
||||
## 77 - PANTALLA DE GAME OVER
|
||||
PUNTUACION J1:
|
||||
## 78 - PANTALLA DE GAME OVER
|
||||
PUNTUACION J2:
|
||||
@@ -33,17 +33,14 @@ Director::Director(std::string path)
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->language = en_UK;
|
||||
mOptions->difficulty = DIFFICULTY_NORMAL;
|
||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
||||
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
mOptions->filter = FILTER_NEAREST;
|
||||
mOptions->vSync = true;
|
||||
}
|
||||
|
||||
// Crea los objetos
|
||||
mInput = new Input(mFileList[52]);
|
||||
//mInput2 = new Input(mOptions->input[1]);
|
||||
//mInput[0] = new Input(INPUT_USE_KEYBOARD);
|
||||
//mInput[1] = new Input(INPUT_USE_GAMECONTROLLER);
|
||||
mInput = new Input(mFileList[53]);
|
||||
|
||||
// Inicializa SDL
|
||||
initSDL();
|
||||
@@ -51,6 +48,11 @@ Director::Director(std::string path)
|
||||
// Inicializa JailAudio
|
||||
initJailAudio();
|
||||
|
||||
// Aplica las opciones
|
||||
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
||||
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
||||
mLang->setLang(mOptions->language);
|
||||
|
||||
#ifdef __MIPSEL__
|
||||
DIR *dir = opendir("/media/data/local/home/.coffee_crisis");
|
||||
if (dir)
|
||||
@@ -126,7 +128,7 @@ void Director::init(Uint8 name)
|
||||
mInput->bindGameControllerButton(INPUT_BUTTON_1, SDL_CONTROLLER_BUTTON_X);
|
||||
mInput->bindGameControllerButton(INPUT_BUTTON_2, SDL_CONTROLLER_BUTTON_Y);
|
||||
mInput->bindGameControllerButton(INPUT_BUTTON_3, SDL_CONTROLLER_BUTTON_B);
|
||||
mInput->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
||||
mInput->bindGameControllerButton(INPUT_BUTTON_PAUSE, SDL_CONTROLLER_BUTTON_GUIDE); // PAUSE
|
||||
mInput->bindGameControllerButton(INPUT_BUTTON_ESCAPE, SDL_CONTROLLER_BUTTON_GUIDE); // ESCAPE
|
||||
}
|
||||
|
||||
@@ -143,13 +145,17 @@ bool Director::initSDL()
|
||||
bool success = true;
|
||||
|
||||
// Inicializa SDL
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0)
|
||||
//if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0)
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
|
||||
{
|
||||
printf("SDL could not initialize!\nSDL Error: %s\n", SDL_GetError());
|
||||
success = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Inicia el generador de numeros aleatorios
|
||||
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
||||
|
||||
// Establece el filtro de la textura a nearest
|
||||
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(mOptions->filter).c_str()))
|
||||
{
|
||||
@@ -259,7 +265,11 @@ void Director::setFileList()
|
||||
mFileList[27] = mExecutablePath + "/" + "../media/font/8bithud.png";
|
||||
mFileList[46] = mExecutablePath + "/" + "../media/font/8bithud.txt";
|
||||
mFileList[28] = mExecutablePath + "/" + "../media/font/nokia.png";
|
||||
mFileList[54] = mExecutablePath + "/" + "../media/font/nokia_big2.png";
|
||||
mFileList[52] = mExecutablePath + "/" + "../media/font/nokia.txt";
|
||||
mFileList[56] = mExecutablePath + "/" + "../media/font/nokia2.png";
|
||||
mFileList[57] = mExecutablePath + "/" + "../media/font/nokia2.txt";
|
||||
mFileList[55] = mExecutablePath + "/" + "../media/font/nokia_big2.txt";
|
||||
mFileList[29] = mExecutablePath + "/" + "../media/font/smb2_big.png";
|
||||
mFileList[47] = mExecutablePath + "/" + "../media/font/smb2_big.txt";
|
||||
mFileList[30] = mExecutablePath + "/" + "../media/font/smb2.png";
|
||||
@@ -269,9 +279,9 @@ void Director::setFileList()
|
||||
mFileList[49] = mExecutablePath + "/" + "../media/lang/es_ES.txt";
|
||||
mFileList[50] = mExecutablePath + "/" + "../media/lang/en_UK.txt";
|
||||
mFileList[51] = mExecutablePath + "/" + "../media/lang/ba_BA.txt";
|
||||
|
||||
|
||||
// DATA
|
||||
mFileList[52] = mExecutablePath + "/" + "../media/data/gamecontrollerdb.txt";
|
||||
mFileList[53] = mExecutablePath + "/" + "../data/gamecontrollerdb.txt";
|
||||
}
|
||||
|
||||
// Comprueba los ficheros del vector de ficheros que coinciden con una ruta dada
|
||||
@@ -345,8 +355,8 @@ bool Director::loadConfigFile()
|
||||
mOptions->windowSize = 3;
|
||||
mOptions->language = en_UK;
|
||||
mOptions->difficulty = DIFFICULTY_NORMAL;
|
||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
||||
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
mOptions->filter = FILTER_NEAREST;
|
||||
mOptions->vSync = true;
|
||||
|
||||
@@ -373,8 +383,8 @@ bool Director::loadConfigFile()
|
||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[0], sizeof(mOptions->input[0]), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[1], sizeof(mOptions->input[1]), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
|
||||
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||
|
||||
@@ -396,8 +406,8 @@ bool Director::loadConfigFile()
|
||||
SDL_RWread(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWread(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
SDL_RWread(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||
SDL_RWread(file, &mOptions->input[0], sizeof(mOptions->input[0]), 1);
|
||||
SDL_RWread(file, &mOptions->input[1], sizeof(mOptions->input[1]), 1);
|
||||
SDL_RWread(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
|
||||
SDL_RWread(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
|
||||
SDL_RWread(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||
SDL_RWread(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||
|
||||
@@ -411,11 +421,6 @@ bool Director::loadConfigFile()
|
||||
if ((mOptions->language < 0) || (mOptions->language > MAX_LANGUAGES))
|
||||
mOptions->language = en_UK;
|
||||
|
||||
// Aplica las opciones
|
||||
SDL_SetWindowFullscreen(mWindow, mOptions->fullScreenMode);
|
||||
SDL_SetWindowSize(mWindow, SCREEN_WIDTH * mOptions->windowSize, SCREEN_HEIGHT * mOptions->windowSize);
|
||||
mLang->setLang(mOptions->language);
|
||||
|
||||
// Cierra el fichero
|
||||
SDL_RWclose(file);
|
||||
}
|
||||
@@ -437,8 +442,8 @@ bool Director::saveConfigFile()
|
||||
SDL_RWwrite(file, &mOptions->windowSize, sizeof(mOptions->windowSize), 1);
|
||||
SDL_RWwrite(file, &mOptions->language, sizeof(mOptions->language), 1);
|
||||
SDL_RWwrite(file, &mOptions->difficulty, sizeof(mOptions->difficulty), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[0], sizeof(mOptions->input[0]), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[1], sizeof(mOptions->input[1]), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[0].deviceType, sizeof(mOptions->input[0].deviceType), 1);
|
||||
SDL_RWwrite(file, &mOptions->input[1].deviceType, sizeof(mOptions->input[1].deviceType), 1);
|
||||
SDL_RWwrite(file, &mOptions->filter, sizeof(mOptions->filter), 1);
|
||||
SDL_RWwrite(file, &mOptions->vSync, sizeof(mOptions->vSync), 1);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "game.h"
|
||||
#include "input.h"
|
||||
#include "fade.h"
|
||||
#include <math.h>
|
||||
//#include <math.h>
|
||||
|
||||
#ifndef DIRECTOR_H
|
||||
#define DIRECTOR_H
|
||||
|
||||
@@ -13,13 +13,13 @@ Game::Game(int numPlayers, SDL_Renderer *renderer, std::string *filelist, Lang *
|
||||
mLang = lang;
|
||||
mInput = input;
|
||||
mOptions = options;
|
||||
mOnePlayerControl = mOptions->input[0];
|
||||
mOnePlayerControl = mOptions->input[0].deviceType;
|
||||
|
||||
// Pasa variables
|
||||
mDemo.enabled = demo;
|
||||
mNumPlayers = numPlayers;
|
||||
if (mNumPlayers == 1)
|
||||
mOptions->input[0] = INPUT_USE_ANY;
|
||||
mOptions->input[0].deviceType = INPUT_USE_ANY;
|
||||
mDifficulty = mOptions->difficulty;
|
||||
|
||||
// Crea los objetos
|
||||
@@ -50,10 +50,14 @@ Game::Game(int numPlayers, SDL_Renderer *renderer, std::string *filelist, Lang *
|
||||
mTextureText = new LTexture();
|
||||
mTextureTextScoreBoard = new LTexture();
|
||||
mTextureTextBig = new LTexture();
|
||||
mTextureTextNokia2 = new LTexture();
|
||||
mTextureTextNokiaBig2 = new LTexture();
|
||||
|
||||
mText = new Text(mFileList[48], mTextureText, mRenderer);
|
||||
mTextScoreBoard = new Text(mFileList[46], mTextureTextScoreBoard, mRenderer);
|
||||
mTextBig = new Text(mFileList[47], mTextureTextBig, mRenderer);
|
||||
mTextNokia2 = new Text(mFileList[57], mTextureTextNokia2, mRenderer);
|
||||
mTextNokiaBig2 = new Text(mFileList[55], mTextureTextNokiaBig2, mRenderer);
|
||||
|
||||
mMenuGameOver = new Menu(mRenderer, mText, mInput, mFileList);
|
||||
mMenuPause = new Menu(mRenderer, mText, mInput, mFileList);
|
||||
@@ -93,7 +97,7 @@ Game::~Game()
|
||||
saveScoreFile();
|
||||
saveDemoFile();
|
||||
|
||||
mOptions->input[0] = mOnePlayerControl;
|
||||
mOptions->input[0].deviceType = mOnePlayerControl;
|
||||
|
||||
mRenderer = nullptr;
|
||||
mFileList = nullptr;
|
||||
@@ -190,14 +194,28 @@ Game::~Game()
|
||||
delete mTextureTextBig;
|
||||
mTextureTextBig = nullptr;
|
||||
|
||||
mTextureTextNokia2->unload();
|
||||
delete mTextureTextNokia2;
|
||||
mTextureTextNokia2 = nullptr;
|
||||
|
||||
mTextureTextNokiaBig2->unload();
|
||||
delete mTextureTextNokiaBig2;
|
||||
mTextureTextNokiaBig2 = nullptr;
|
||||
|
||||
delete mText;
|
||||
mText = nullptr;
|
||||
|
||||
delete mTextBig;
|
||||
mTextBig = nullptr;
|
||||
|
||||
delete mTextScoreBoard;
|
||||
mTextScoreBoard = nullptr;
|
||||
|
||||
delete mTextureTextBig;
|
||||
mTextureTextBig = nullptr;
|
||||
delete mTextNokia2;
|
||||
mTextNokia2 = nullptr;
|
||||
|
||||
delete mTextNokiaBig2;
|
||||
mTextNokiaBig2 = nullptr;
|
||||
|
||||
delete mMenuGameOver;
|
||||
mMenuGameOver = nullptr;
|
||||
@@ -370,6 +388,9 @@ void Game::init()
|
||||
initEnemyPools();
|
||||
initGameStages();
|
||||
|
||||
// BORRAR
|
||||
//mStage[mCurrentStage].currentPower = mStage[mCurrentStage].powerToComplete - 10;
|
||||
|
||||
// Modo debug
|
||||
mDebug.enabled = false;
|
||||
mDebug.enemySet = 0;
|
||||
@@ -523,6 +544,8 @@ bool Game::loadMedia()
|
||||
success &= loadTextureFromFile(mTextureText, mFileList[30], mRenderer);
|
||||
success &= loadTextureFromFile(mTextureTextScoreBoard, mFileList[27], mRenderer);
|
||||
success &= loadTextureFromFile(mTextureTextBig, mFileList[29], mRenderer);
|
||||
success &= loadTextureFromFile(mTextureTextNokia2, mFileList[56], mRenderer);
|
||||
success &= loadTextureFromFile(mTextureTextNokiaBig2, mFileList[54], mRenderer);
|
||||
|
||||
success &= loadTextureFromFile(mTexturePlayer1Legs, mFileList[39], mRenderer);
|
||||
success &= loadTextureFromFile(mTexturePlayer1Head, mFileList[41], mRenderer);
|
||||
@@ -2065,8 +2088,8 @@ void Game::destroyBalloon(Uint8 index)
|
||||
}
|
||||
|
||||
// Otorga los puntos correspondientes al globo
|
||||
mPlayer[0]->addScore(Uint32(score * mPlayer[0]->getScoreMultiplier() * mDifficultyScoreMultiplier));
|
||||
//setScore(mPlayer[0]->getScore());
|
||||
for (int i = 0; i < mNumPlayers; i++)
|
||||
mPlayer[i]->addScore(Uint32(score * mPlayer[i]->getScoreMultiplier() * mDifficultyScoreMultiplier));
|
||||
updateHiScore();
|
||||
|
||||
// Aumenta el poder de la fase
|
||||
@@ -2259,7 +2282,7 @@ void Game::moveBullets()
|
||||
for (int i = 0; i < MAX_BULLETS; i++)
|
||||
if (mBullet[i]->isActive())
|
||||
if (mBullet[i]->move() == MSG_BULLET_OUT)
|
||||
mPlayer[0]->decScoreMultiplier();
|
||||
mPlayer[mBullet[i]->getOwner()]->decScoreMultiplier();
|
||||
}
|
||||
|
||||
// Pinta las balas activas
|
||||
@@ -2334,10 +2357,10 @@ void Game::resetItems()
|
||||
// Devuelve un item en función del azar
|
||||
Uint8 Game::dropItem()
|
||||
{
|
||||
if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled))
|
||||
return NO_KIND;
|
||||
else
|
||||
return ITEM_COFFEE_MACHINE;
|
||||
//if (mPlayer[0]->isPowerUp() || (mCoffeeMachineEnabled))
|
||||
// return NO_KIND;
|
||||
//else
|
||||
// return ITEM_COFFEE_MACHINE;
|
||||
|
||||
const Uint8 luckyNumber = rand() % 100;
|
||||
const Uint8 item = rand() % 6;
|
||||
@@ -2861,7 +2884,7 @@ void Game::checkGameInput()
|
||||
if (mPlayer[i]->isAlive())
|
||||
{
|
||||
// Input a la izquierda
|
||||
if (mInput->checkInput(INPUT_LEFT, REPEAT_TRUE, mOptions->input[i]))
|
||||
if (mInput->checkInput(INPUT_LEFT, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||
{
|
||||
mPlayer[i]->setInput(INPUT_LEFT);
|
||||
mDemo.keys.left = 1;
|
||||
@@ -2869,7 +2892,7 @@ void Game::checkGameInput()
|
||||
else
|
||||
{
|
||||
// Input a la derecha
|
||||
if (mInput->checkInput(INPUT_RIGHT, REPEAT_TRUE, mOptions->input[i]))
|
||||
if (mInput->checkInput(INPUT_RIGHT, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||
{
|
||||
mPlayer[i]->setInput(INPUT_RIGHT);
|
||||
mDemo.keys.right = 1;
|
||||
@@ -2882,7 +2905,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
}
|
||||
// Comprueba el input de disparar al centro
|
||||
if (mInput->checkInput(INPUT_BUTTON_2, REPEAT_TRUE, mOptions->input[i]))
|
||||
if (mInput->checkInput(INPUT_BUTTON_2, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||
{
|
||||
if (mPlayer[i]->canFire())
|
||||
{
|
||||
@@ -2898,7 +2921,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la izquierda
|
||||
if (mInput->checkInput(INPUT_BUTTON_1, REPEAT_TRUE, mOptions->input[i]))
|
||||
if (mInput->checkInput(INPUT_BUTTON_1, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||
{
|
||||
if (mPlayer[i]->canFire())
|
||||
{
|
||||
@@ -2914,7 +2937,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
|
||||
// Comprueba el input de disparar a la derecha
|
||||
if (mInput->checkInput(INPUT_BUTTON_3, REPEAT_TRUE, mOptions->input[i]))
|
||||
if (mInput->checkInput(INPUT_BUTTON_3, REPEAT_TRUE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||
{
|
||||
if (mPlayer[i]->canFire())
|
||||
{
|
||||
@@ -2930,7 +2953,7 @@ void Game::checkGameInput()
|
||||
}
|
||||
|
||||
// Comprueba el input de pausa
|
||||
if (mInput->checkInput(INPUT_CANCEL, REPEAT_FALSE, mOptions->input[i]))
|
||||
if (mInput->checkInput(INPUT_CANCEL, REPEAT_FALSE, mOptions->input[i].deviceType, mOptions->input[i].id))
|
||||
{
|
||||
mSection.subsection = GAME_SECTION_PAUSE;
|
||||
|
||||
@@ -2959,16 +2982,21 @@ void Game::renderMessages()
|
||||
{
|
||||
mSpriteGetReady->setPosX((int)mGetReadyBitmapPath[mCounter]);
|
||||
//mSpriteGetReady->render();
|
||||
const color_t color = {0x17, 0x17, 0x26};
|
||||
//const color_t color = {0x17, 0x17, 0x26};
|
||||
//mTextBig->writeShadowed((int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), color, 2);
|
||||
mTextBig->writeDX(TXT_STROKE, (int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), 1, noColor, 1, shdwTxtColor);
|
||||
//mTextBig->writeDX(TXT_STROKE, (int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), 1, noColor, 1, shdwTxtColor);
|
||||
mTextNokiaBig2->write((int)mGetReadyBitmapPath[mCounter], PLAY_AREA_CENTER_Y - 8, mLang->getText(75), -2);
|
||||
}
|
||||
|
||||
// Time Stopped
|
||||
if (mTimeStopped)
|
||||
{
|
||||
if ((mTimeStoppedCounter > 100) || (mTimeStoppedCounter % 10 > 4))
|
||||
mText->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36) + std::to_string(mTimeStoppedCounter / 10), 1, noColor, 1, shdwTxtColor);
|
||||
mTextNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36) + std::to_string(mTimeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor);
|
||||
//{
|
||||
// mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(36), -2);
|
||||
// mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y + mTextNokiaBig2->getCharacterWidth() + 2, std::to_string(mTimeStoppedCounter / 10), -2);
|
||||
//}
|
||||
|
||||
if (mTimeStoppedCounter > 100)
|
||||
{
|
||||
@@ -2985,7 +3013,7 @@ void Game::renderMessages()
|
||||
// D E M O
|
||||
if (mDemo.enabled)
|
||||
if (mDemo.counter % 30 > 14)
|
||||
mTextBig->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(37), 0, noColor, 2, shdwTxtColor);
|
||||
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, mLang->getText(37), 0, noColor, 2, shdwTxtColor);
|
||||
|
||||
// STAGE NUMBER
|
||||
if (mStageBitmapCounter < STAGE_COUNTER)
|
||||
@@ -2993,13 +3021,13 @@ void Game::renderMessages()
|
||||
std::string text = mLang->getText(38) + std::to_string(mStage[mCurrentStage].number);
|
||||
if (!mGameCompleted)
|
||||
{
|
||||
mTextBig->writeDX(TXT_CENTER | TXT_SHADOW, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, 1, noColor, 2, shdwTxtColor);
|
||||
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, -2, noColor, 2, shdwTxtColor);
|
||||
}
|
||||
else
|
||||
{ // Texto de juego completado
|
||||
text = mLang->getText(50);
|
||||
mTextBig->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, 1, noColor, 1, shdwTxtColor);
|
||||
mText->writeDX(TXT_CENTER | TXT_STROKE, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter] + 17, mLang->getText(76), 1, noColor, 1, shdwTxtColor);
|
||||
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter], text, -2, noColor, 1, shdwTxtColor);
|
||||
mTextNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, mStageBitmapPath[mStageBitmapCounter] + mTextNokiaBig2->getCharacterWidth() + 2, mLang->getText(76), -1, noColor, 1, shdwTxtColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3271,6 +3299,9 @@ void Game::runPausedGame()
|
||||
// Bucle para la pantalla de game over
|
||||
void Game::runGameOverScreen()
|
||||
{
|
||||
// Guarda los puntos
|
||||
saveScoreFile();
|
||||
|
||||
// Reinicia el menu
|
||||
mMenuGameOver->reset();
|
||||
|
||||
@@ -3327,8 +3358,17 @@ void Game::runGameOverScreen()
|
||||
SDL_RenderClear(mRenderer);
|
||||
|
||||
// Dibuja los objetos
|
||||
mTextBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), mLang->getText(43));
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), mLang->getText(44) + std::to_string(mPlayer[0]->getScore()));
|
||||
if (mNumPlayers == 1)
|
||||
{
|
||||
mTextBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), mLang->getText(43));
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 1), mLang->getText(44) + std::to_string(mPlayer[0]->getScore()));
|
||||
}
|
||||
else
|
||||
{
|
||||
mTextBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - 36, mLang->getText(43));
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - 12, mLang->getText(77) + std::to_string(mPlayer[0]->getScore()));
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y, mLang->getText(78) + std::to_string(mPlayer[1]->getScore()));
|
||||
}
|
||||
mText->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y + BLOCK * 2, mLang->getText(45));
|
||||
mMenuGameOver->render();
|
||||
mFade->render();
|
||||
@@ -3424,7 +3464,7 @@ void Game::initPaths()
|
||||
}
|
||||
|
||||
// Letrero de GetReady
|
||||
const int size = mTextBig->lenght(mLang->getText(75));
|
||||
const int size = mTextNokiaBig2->lenght(mLang->getText(75), -2);
|
||||
|
||||
const float start1 = PLAY_AREA_LEFT - size;
|
||||
const float finish1 = PLAY_AREA_CENTER_X - (size / 2);
|
||||
@@ -3467,6 +3507,7 @@ void Game::updateGameCompleted()
|
||||
// Actualiza las variables de ayuda
|
||||
void Game::updateHelper()
|
||||
{
|
||||
// El ayudante solo funciona para un jugador
|
||||
// Solo ofrece ayuda cuando la amenaza o la velocidad es elevada
|
||||
if (mMenaceCurrent > 15)
|
||||
{
|
||||
|
||||
@@ -108,10 +108,14 @@ private:
|
||||
LTexture *mTextureText; // Textura para el texto del juego
|
||||
LTexture *mTextureTextScoreBoard; // Textura para el texto del marcador
|
||||
LTexture *mTextureTextBig; // Textura para el texto grande
|
||||
LTexture *mTextureTextNokia2; // Textura para la fuente de texto Nokia
|
||||
LTexture *mTextureTextNokiaBig2; // Textura para la fuente de texto Nokia grande
|
||||
|
||||
Text *mText; // Fuente para los textos del juego
|
||||
Text *mTextScoreBoard; // Fuente para el marcador del juego
|
||||
Text *mTextBig; // Fuente de texto grande
|
||||
Text *mTextScoreBoard; // Fuente para el marcador del juego
|
||||
Text *mTextNokia2; // Otra fuente de texto para mesajes
|
||||
Text *mTextNokiaBig2; // Y la versión en grande
|
||||
|
||||
Menu *mMenuGameOver; // Menú de la pantalla de game over
|
||||
Menu *mMenuPause; // Menú de la pantalla de pausa
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "input.h"
|
||||
//#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
// Contestar cuantos joystics ha detectado
|
||||
// Preguntarlepor los joystics que ha encontrado para ir poniendolos en la variable de opciones
|
||||
|
||||
// Constructor
|
||||
Input::Input(std::string file)
|
||||
{
|
||||
@@ -24,9 +26,8 @@ Input::Input(std::string file)
|
||||
// Destructor
|
||||
Input::~Input()
|
||||
{
|
||||
//SDL_GameControllerClose(mGameController);
|
||||
//if (mGameController)
|
||||
mGameController = nullptr;
|
||||
for (int i = 0; i < mNumGamepads; i++)
|
||||
mConnectedControllers[i] = nullptr;
|
||||
}
|
||||
|
||||
// Asigna uno de los posibles inputs a una tecla del teclado
|
||||
@@ -42,11 +43,14 @@ void Input::bindGameControllerButton(Uint8 input, SDL_GameControllerButton butto
|
||||
}
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
bool Input::checkInput(Uint8 input, bool repeat, int device)
|
||||
bool Input::checkInput(Uint8 input, bool repeat, int device, int index)
|
||||
{
|
||||
bool successKeyboard = false;
|
||||
bool successGameController = false;
|
||||
|
||||
if (device == INPUT_USE_ANY)
|
||||
index = 0;
|
||||
|
||||
if ((device == INPUT_USE_KEYBOARD) || (device == INPUT_USE_ANY))
|
||||
{
|
||||
const Uint8 *mKeystates = SDL_GetKeyboardState(NULL);
|
||||
@@ -92,7 +96,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device)
|
||||
{
|
||||
if (repeat)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(mGameController, mGameControllerBindings[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
||||
successGameController = true;
|
||||
else
|
||||
successGameController = false;
|
||||
@@ -101,7 +105,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device)
|
||||
{
|
||||
if (!mGameControllerBindings[input].active)
|
||||
{
|
||||
if (SDL_GameControllerGetButton(mGameController, mGameControllerBindings[input].button) != 0)
|
||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) != 0)
|
||||
{
|
||||
mGameControllerBindings[input].active = true;
|
||||
successGameController = true;
|
||||
@@ -113,7 +117,7 @@ bool Input::checkInput(Uint8 input, bool repeat, int device)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SDL_GameControllerGetButton(mGameController, mGameControllerBindings[input].button) == 0)
|
||||
if (SDL_GameControllerGetButton(mConnectedControllers[index], mGameControllerBindings[input].button) == 0)
|
||||
{
|
||||
mGameControllerBindings[input].active = false;
|
||||
successGameController = false;
|
||||
@@ -137,6 +141,9 @@ bool Input::discoverGameController()
|
||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) != 1)
|
||||
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
|
||||
if (SDL_GameControllerAddMappingsFromFile(mDBpath.c_str()) < 0)
|
||||
printf("Error, could not load %s file: %s\n", mDBpath.c_str(), SDL_GetError());
|
||||
|
||||
int nJoysticks = SDL_NumJoysticks();
|
||||
mNumGamepads = 0;
|
||||
|
||||
@@ -159,18 +166,19 @@ bool Input::discoverGameController()
|
||||
if (SDL_GameControllerGetAttached(pad) == 1)
|
||||
{
|
||||
mConnectedControllers.push_back(pad);
|
||||
std::string separator(" #");
|
||||
std::string name = SDL_GameControllerNameForIndex(i);
|
||||
std::cout << SDL_GameControllerNameForIndex(i) << std::endl;
|
||||
name.resize(25);
|
||||
name = name + separator + std::to_string(i);
|
||||
std::cout << name << std::endl;
|
||||
mControllerNames.push_back(name);
|
||||
}
|
||||
else
|
||||
std::cout << "SDL_GetError() = " << SDL_GetError() << std::endl;
|
||||
}
|
||||
|
||||
mGameController = mConnectedControllers[0];
|
||||
//mGameController = mConnectedControllers[0];
|
||||
SDL_GameControllerEventState(SDL_ENABLE);
|
||||
SDL_GameControllerAddMappingsFromFile(mDBpath.c_str());
|
||||
}
|
||||
|
||||
return found;
|
||||
@@ -191,5 +199,11 @@ std::string Input::getControllerName(int index)
|
||||
if (mNumGamepads > 0)
|
||||
return mControllerNames[index];
|
||||
else
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int Input::getNumControllers()
|
||||
{
|
||||
return mNumGamepads;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ private:
|
||||
};
|
||||
GameControllerBindings_t mGameControllerBindings[17]; // Vector con las teclas asociadas a los inputs predefinidos
|
||||
|
||||
SDL_GameController *mGameController; // Manejador para el mando
|
||||
//SDL_GameController *mGameController; // Manejador para el mando
|
||||
std::vector<SDL_GameController*> mConnectedControllers;
|
||||
std::vector<std::string> mControllerNames;
|
||||
int mNumGamepads;
|
||||
@@ -72,11 +72,14 @@ public:
|
||||
void bindGameControllerButton(Uint8 input, SDL_GameControllerButton button);
|
||||
|
||||
// Comprueba si un input esta activo
|
||||
bool checkInput(Uint8 input, bool repeat, int device=INPUT_USE_ANY);
|
||||
bool checkInput(Uint8 input, bool repeat, int device=INPUT_USE_ANY, int index=0);
|
||||
|
||||
// Comprueba si hay algun mando conectado
|
||||
bool gameControllerFound();
|
||||
|
||||
// Obten el numero de mandos conectados
|
||||
int getNumControllers();
|
||||
|
||||
// Obten el nombre de un mando de juego
|
||||
std::string getControllerName(int index);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
# define INIT_FADE 100
|
||||
# define END_LOGO 200
|
||||
|
||||
// Constructor
|
||||
Logo::Logo(SDL_Renderer *renderer, std::string *fileList)
|
||||
{
|
||||
@@ -71,6 +74,7 @@ section_t Logo::run()
|
||||
{
|
||||
init();
|
||||
const SDL_Rect rect = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
|
||||
const int fadeLenght = END_LOGO - INIT_FADE;
|
||||
|
||||
while (mSection.name == PROG_SECTION_LOGO)
|
||||
{
|
||||
@@ -92,9 +96,6 @@ section_t Logo::run()
|
||||
}
|
||||
}
|
||||
|
||||
// Cambia el destino donde se pinta todo
|
||||
//SDL_SetRenderTarget(mRenderer, mBackbuffer);
|
||||
|
||||
// Limpia el destino
|
||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||
SDL_RenderClear(mRenderer);
|
||||
@@ -103,22 +104,16 @@ section_t Logo::run()
|
||||
mSprite->render();
|
||||
|
||||
// Dibuja el fade
|
||||
if (mCounter >= 200)
|
||||
if (mCounter >= INIT_FADE)
|
||||
{
|
||||
Uint16 alpha = mCounter - 200;
|
||||
Uint16 alpha = (255 * (mCounter - INIT_FADE)) / fadeLenght;
|
||||
if (alpha < 256)
|
||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, alpha);
|
||||
else
|
||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255); // alpha - 0 trans, 255 opaco
|
||||
SDL_SetRenderDrawColor(mRenderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||
SDL_RenderFillRect(mRenderer, &rect);
|
||||
}
|
||||
|
||||
// Vuelve a usar el renderizador como destino
|
||||
//SDL_SetRenderTarget(mRenderer, NULL);
|
||||
|
||||
// Copia el backbufer al renderizador
|
||||
//SDL_RenderCopy(mRenderer, mBackbuffer, NULL, NULL);
|
||||
|
||||
// Actualiza la pantalla
|
||||
SDL_RenderPresent(mRenderer);
|
||||
|
||||
@@ -134,7 +129,7 @@ section_t Logo::run()
|
||||
JA_StopMusic();
|
||||
}
|
||||
|
||||
if (mCounter == 500) // minimo 200 + 255
|
||||
if (mCounter == END_LOGO + 20)
|
||||
{
|
||||
mCounter = 0;
|
||||
mSection.name = PROG_SECTION_INTRO;
|
||||
|
||||
@@ -36,13 +36,9 @@ un tipo asociado diferente a NO_KIND
|
||||
|
||||
#include "director.h"
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char *args[])
|
||||
{
|
||||
// Inicia el generador de numeros aleatorios
|
||||
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
||||
|
||||
printf("Starting the game...\n\n");
|
||||
|
||||
// Crea el objeto Director
|
||||
@@ -54,6 +50,7 @@ int main(int argc, char *args[])
|
||||
// Destruye el objeto Director
|
||||
delete mDirector;
|
||||
mDirector = nullptr;
|
||||
|
||||
printf("\nShutting down the game...\n");
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -143,6 +143,7 @@ void Text::initOffsetFromFile()
|
||||
if (rfile.is_open() && rfile.good())
|
||||
{
|
||||
std::string buffer;
|
||||
//printf("Reading %s file\n", mFile.c_str());
|
||||
|
||||
// Lee los dos primeros valores del fichero
|
||||
std::getline(rfile, buffer);
|
||||
|
||||
119
source/title.cpp
@@ -136,10 +136,27 @@ void Title::init(bool demo, Uint8 subsection)
|
||||
mFade->init(0x17, 0x17, 0x26);
|
||||
mDemo = demo;
|
||||
|
||||
if (!mInput->gameControllerFound())
|
||||
//if (!mInput->gameControllerFound())
|
||||
{
|
||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
||||
mOptions->input[0].id = 0;
|
||||
mOptions->input[0].name = "KEYBOARD";
|
||||
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||
|
||||
mOptions->input[1].id = 0;
|
||||
mOptions->input[1].name = "GAME CONTROLLER";
|
||||
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
}
|
||||
|
||||
checkInputDevices();
|
||||
|
||||
mDeviceIndex[0] = mAvailableInputDevices.size() - 1;
|
||||
mDeviceIndex[1] = 0;
|
||||
|
||||
if (mInput->gameControllerFound())
|
||||
{
|
||||
mOptions->input[1].id = mAvailableInputDevices[mDeviceIndex[1]].id;
|
||||
mOptions->input[1].name = mAvailableInputDevices[mDeviceIndex[1]].name;
|
||||
mOptions->input[1].deviceType = mAvailableInputDevices[mDeviceIndex[1]].deviceType;
|
||||
}
|
||||
|
||||
// Inicializa el bitmap de Coffee
|
||||
@@ -349,7 +366,7 @@ void Title::updateMenuLabels()
|
||||
|
||||
i++;
|
||||
// PLAYER 1 CONTROLS - OPTIONS
|
||||
switch (mOptions->input[0])
|
||||
switch (mOptions->input[0].deviceType)
|
||||
{
|
||||
case INPUT_USE_KEYBOARD:
|
||||
mMenu.options->setItemCaption(i, mLang->getText(69)); // KEYBOARD
|
||||
@@ -363,7 +380,8 @@ void Title::updateMenuLabels()
|
||||
else
|
||||
{
|
||||
mMenu.options->setGreyed(i, false);
|
||||
mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
||||
//mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
||||
mMenu.options->setItemCaption(i, mOptions->input[0].name);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -378,7 +396,7 @@ void Title::updateMenuLabels()
|
||||
|
||||
i++;
|
||||
// PLAYER 2 CONTROLS - OPTIONS
|
||||
switch (mOptions->input[1])
|
||||
switch (mOptions->input[1].deviceType)
|
||||
{
|
||||
case INPUT_USE_KEYBOARD:
|
||||
mMenu.options->setItemCaption(i, mLang->getText(69)); // KEYBOARD
|
||||
@@ -392,7 +410,8 @@ void Title::updateMenuLabels()
|
||||
else
|
||||
{
|
||||
mMenu.options->setGreyed(i, false);
|
||||
mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
||||
//mMenu.options->setItemCaption(i, mInput->getControllerName(0));
|
||||
mMenu.options->setItemCaption(i, mOptions->input[1].name);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -755,11 +774,11 @@ section_t Title::run(Uint8 subsection)
|
||||
updateMenuLabels();
|
||||
break;
|
||||
case 1: // PLAYER 1 CONTROLS
|
||||
switchInputs(1);
|
||||
updatePlayerInputs(0);
|
||||
updateMenuLabels();
|
||||
break;
|
||||
case 3: // PLAYER 2 CONTROLS
|
||||
switchInputs(2);
|
||||
updatePlayerInputs(1);
|
||||
updateMenuLabels();
|
||||
break;
|
||||
case 5: // Language
|
||||
@@ -908,17 +927,58 @@ void Title::runDemoGame()
|
||||
}
|
||||
|
||||
// Modifica las opciones para los controles de los jugadores
|
||||
void Title::switchInputs(int value)
|
||||
bool Title::updatePlayerInputs(int numPlayer)
|
||||
{
|
||||
Uint8 temp;
|
||||
temp = mOptions->input[0];
|
||||
mOptions->input[0] = mOptions->input[1];
|
||||
mOptions->input[1] = temp;
|
||||
const int numDevices = mAvailableInputDevices.size();
|
||||
|
||||
// Si no hay mandos se deja todo de manera prefijada
|
||||
if (!mInput->gameControllerFound())
|
||||
{
|
||||
mOptions->input[0] = INPUT_USE_KEYBOARD;
|
||||
mOptions->input[1] = INPUT_USE_GAMECONTROLLER;
|
||||
mDeviceIndex[0] = 0;
|
||||
mDeviceIndex[1] = 0;
|
||||
|
||||
mOptions->input[0].id = -1;
|
||||
mOptions->input[0].name = "KEYBOARD";
|
||||
mOptions->input[0].deviceType = INPUT_USE_KEYBOARD;
|
||||
|
||||
mOptions->input[1].id = 0;
|
||||
mOptions->input[1].name = "GAME CONTROLLER";
|
||||
mOptions->input[1].deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
|
||||
return true;
|
||||
}
|
||||
else // Si hay mas de un dispositivo, se recorre el vector
|
||||
{
|
||||
printf("numplayer:%i\n",numPlayer);
|
||||
printf("deviceindex:%i\n",mDeviceIndex[numPlayer]);
|
||||
|
||||
// Incrementa el indice
|
||||
if (mDeviceIndex[numPlayer] < numDevices - 1)
|
||||
mDeviceIndex[numPlayer]++;
|
||||
else
|
||||
mDeviceIndex[numPlayer] = 0;
|
||||
printf("deviceindex:%i\n",mDeviceIndex[numPlayer]);
|
||||
|
||||
// Si coincide con el del otro jugador, se lo intercambian
|
||||
if (mDeviceIndex[0] == mDeviceIndex[1])
|
||||
{
|
||||
printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]);
|
||||
|
||||
//const int temp = mDeviceIndex[0];
|
||||
//mDeviceIndex[0] = mDeviceIndex[1];
|
||||
//mDeviceIndex[1] = temp;
|
||||
const int theOtherPlayer = (numPlayer + 1) % 2;
|
||||
mDeviceIndex[theOtherPlayer]--;
|
||||
if (mDeviceIndex[theOtherPlayer] < 0)
|
||||
mDeviceIndex[theOtherPlayer]=numDevices-1;
|
||||
printf("%i:%i\n",mDeviceIndex[0],mDeviceIndex[1]);
|
||||
}
|
||||
|
||||
// Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador
|
||||
mOptions->input[0] = mAvailableInputDevices[mDeviceIndex[0]];
|
||||
mOptions->input[1] = mAvailableInputDevices[mDeviceIndex[1]];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,4 +1000,31 @@ void Title::createTiledBackground()
|
||||
}
|
||||
|
||||
SDL_SetRenderTarget(mRenderer, nullptr);
|
||||
}
|
||||
|
||||
// Comprueba cuantos mandos hay conectados para gestionar el menu de opciones
|
||||
void Title::checkInputDevices()
|
||||
{
|
||||
printf("Filling devices for options menu...\n");
|
||||
int numControllers = mInput->getNumControllers();
|
||||
mAvailableInputDevices.clear();
|
||||
input_t temp;
|
||||
|
||||
// Añade todos los mandos
|
||||
if (numControllers > 0)
|
||||
for (int i = 0; i < numControllers; i++)
|
||||
{
|
||||
temp.id = i;
|
||||
temp.name = mInput->getControllerName(i);
|
||||
temp.deviceType = INPUT_USE_GAMECONTROLLER;
|
||||
mAvailableInputDevices.push_back(temp);
|
||||
printf("Device %i:\t%s\n", (int)mAvailableInputDevices.size(), temp.name.c_str());
|
||||
}
|
||||
|
||||
// Añade el teclado al final
|
||||
temp.id = -1;
|
||||
temp.name = "KEYBOARD";
|
||||
temp.deviceType = INPUT_USE_KEYBOARD;
|
||||
mAvailableInputDevices.push_back(temp);
|
||||
printf("Device %i:\t%s\n\n", (int)mAvailableInputDevices.size(), temp.name.c_str());
|
||||
}
|
||||
@@ -72,6 +72,8 @@ private:
|
||||
|
||||
struct options_t *mOptions; // Variable con todas las variables de las opciones del programa
|
||||
options_t mOptionsPrevious; // Variable de respaldo para las opciones
|
||||
std::vector<input_t> mAvailableInputDevices; // Vector con todos los metodos de control disponibles
|
||||
int mDeviceIndex[2]; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
|
||||
|
||||
// Carga los recursos necesarios para la sección 'Title'
|
||||
bool loadMedia();
|
||||
@@ -92,11 +94,14 @@ private:
|
||||
void runDemoGame();
|
||||
|
||||
// Modifica las opciones para los controles de los jugadores
|
||||
void switchInputs(int value);
|
||||
bool updatePlayerInputs(int numPlayer);
|
||||
|
||||
// Crea el mosaico de fondo del titulo
|
||||
void createTiledBackground();
|
||||
|
||||
// Comprueba cuantos mandos hay conectados para gestionar el menu de opciones
|
||||
void checkInputDevices();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Title(SDL_Window *window, SDL_Renderer *renderer, Input *input, std::string *fileList, options_t *options, Lang *lang);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "ifdefs.h"
|
||||
#include "ltexture.h"
|
||||
#include <string>
|
||||
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
@@ -39,11 +40,19 @@ struct demoKeys_t
|
||||
Uint8 fireRight;
|
||||
};
|
||||
|
||||
// Estructura para albergar métodos de control
|
||||
struct input_t
|
||||
{
|
||||
int id; // Identificador en el vector de mandos
|
||||
std::string name; // Nombre del dispositivo
|
||||
Uint8 deviceType; // Tipo de dispositivo (teclado o mando)
|
||||
};
|
||||
|
||||
// Estructura con todas las opciones de configuración del programa
|
||||
struct options_t
|
||||
{
|
||||
Uint8 difficulty; // Dificultad del juego
|
||||
Uint8 input[2]; // Modo de control (teclado o mando)
|
||||
input_t input[2]; // Modo de control (teclado o mando)
|
||||
Uint8 language; // Idioma usado en el juego
|
||||
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa
|
||||
Uint8 windowSize; // Contiene el valor del tamaño de la ventana
|
||||
|
||||