clang-format
This commit is contained in:
22
.clang-format
Normal file
22
.clang-format
Normal file
@@ -0,0 +1,22 @@
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
NamespaceIndentation: All
|
||||
IndentAccessModifiers: false
|
||||
ColumnLimit: 0 # Sin límite de longitud de línea
|
||||
BreakBeforeBraces: Attach # Llaves en la misma línea
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AlignOperands: DontAlign
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
ContinuationIndentWidth: 4
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
Cpp11BracedListStyle: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
PackConstructorInitializers: Never
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
@@ -66,3 +66,35 @@ endif()
|
||||
|
||||
# Ejecutable en la raíz del proyecto
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
|
||||
# --- CLANG-FORMAT TARGETS ---
|
||||
find_program(CLANG_FORMAT_EXE NAMES clang-format)
|
||||
|
||||
# Recopilar todos los archivos fuente para formateo (excluir external/)
|
||||
file(GLOB_RECURSE ALL_SOURCE_FILES
|
||||
"${CMAKE_SOURCE_DIR}/source/*.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/source/*.hpp"
|
||||
"${CMAKE_SOURCE_DIR}/source/*.h"
|
||||
)
|
||||
list(FILTER ALL_SOURCE_FILES EXCLUDE REGEX ".*/external/.*")
|
||||
|
||||
if(CLANG_FORMAT_EXE)
|
||||
add_custom_target(format
|
||||
COMMAND ${CLANG_FORMAT_EXE}
|
||||
-i
|
||||
${ALL_SOURCE_FILES}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Running clang-format..."
|
||||
)
|
||||
|
||||
add_custom_target(format-check
|
||||
COMMAND ${CLANG_FORMAT_EXE}
|
||||
--dry-run
|
||||
--Werror
|
||||
${ALL_SOURCE_FILES}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Checking clang-format..."
|
||||
)
|
||||
else()
|
||||
message(STATUS "clang-format no encontrado - targets 'format' y 'format-check' no disponibles")
|
||||
endif()
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
#ifndef JA_USESDLMIXER
|
||||
#include "core/jail_audio.hpp"
|
||||
#include "external/stb_vorbis.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "external/stb_vorbis.h"
|
||||
|
||||
#define JA_MAX_SIMULTANEOUS_CHANNELS 5
|
||||
|
||||
struct JA_Sound_t
|
||||
{
|
||||
struct JA_Sound_t {
|
||||
SDL_AudioSpec spec{SDL_AUDIO_S16, 2, 48000};
|
||||
Uint32 length{0};
|
||||
Uint8 *buffer{NULL};
|
||||
};
|
||||
|
||||
struct JA_Channel_t
|
||||
{
|
||||
struct JA_Channel_t {
|
||||
JA_Sound_t *sound{nullptr};
|
||||
int pos{0};
|
||||
int times{0};
|
||||
@@ -22,8 +22,7 @@ struct JA_Channel_t
|
||||
JA_Channel_state state{JA_CHANNEL_FREE};
|
||||
};
|
||||
|
||||
struct JA_Music_t
|
||||
{
|
||||
struct JA_Music_t {
|
||||
SDL_AudioSpec spec{SDL_AUDIO_S16, 2, 48000};
|
||||
Uint32 length{0};
|
||||
Uint8 *buffer{nullptr};
|
||||
@@ -89,10 +88,8 @@ void audioCallback(void * userdata, uint8_t * stream, int len) {
|
||||
}
|
||||
*/
|
||||
|
||||
Uint32 JA_UpdateCallback(void *userdata, SDL_TimerID timerID, Uint32 interval)
|
||||
{
|
||||
if (JA_musicEnabled && current_music && current_music->state == JA_MUSIC_PLAYING)
|
||||
{
|
||||
Uint32 JA_UpdateCallback(void *userdata, SDL_TimerID timerID, Uint32 interval) {
|
||||
if (JA_musicEnabled && current_music && current_music->state == JA_MUSIC_PLAYING) {
|
||||
if (fading) {
|
||||
int time = SDL_GetTicks();
|
||||
if (time > (fade_start_time + fade_duration)) {
|
||||
@@ -106,44 +103,34 @@ Uint32 JA_UpdateCallback(void *userdata, SDL_TimerID timerID, Uint32 interval)
|
||||
}
|
||||
}
|
||||
|
||||
if (current_music->times != 0)
|
||||
{
|
||||
if (current_music->times != 0) {
|
||||
if (SDL_GetAudioStreamAvailable(current_music->stream) < int(current_music->length / 2)) {
|
||||
SDL_PutAudioStreamData(current_music->stream, current_music->buffer, current_music->length);
|
||||
}
|
||||
if (current_music->times > 0) current_music->times--;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (SDL_GetAudioStreamAvailable(current_music->stream) == 0) JA_StopMusic();
|
||||
}
|
||||
}
|
||||
|
||||
if (JA_soundEnabled)
|
||||
{
|
||||
if (JA_soundEnabled) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; ++i)
|
||||
if (channels[i].state == JA_CHANNEL_PLAYING)
|
||||
{
|
||||
if (channels[i].times != 0)
|
||||
{
|
||||
if (channels[i].state == JA_CHANNEL_PLAYING) {
|
||||
if (channels[i].times != 0) {
|
||||
if (SDL_GetAudioStreamAvailable(channels[i].stream) < int(channels[i].sound->length / 2)) {
|
||||
SDL_PutAudioStreamData(channels[i].stream, channels[i].sound->buffer, channels[i].sound->length);
|
||||
if (channels[i].times > 0) channels[i].times--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (SDL_GetAudioStreamAvailable(channels[i].stream) == 0) JA_StopChannel(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 30;
|
||||
}
|
||||
|
||||
void JA_Init(const int freq, const SDL_AudioFormat format, const int num_channels)
|
||||
{
|
||||
void JA_Init(const int freq, const SDL_AudioFormat format, const int num_channels) {
|
||||
#ifdef DEBUG
|
||||
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
|
||||
#endif
|
||||
@@ -158,16 +145,14 @@ void JA_Init(const int freq, const SDL_AudioFormat format, const int num_channel
|
||||
JA_timerID = SDL_AddTimer(30, JA_UpdateCallback, nullptr);
|
||||
}
|
||||
|
||||
void JA_Quit()
|
||||
{
|
||||
void JA_Quit() {
|
||||
if (JA_timerID) SDL_RemoveTimer(JA_timerID);
|
||||
|
||||
if (!sdlAudioDevice) SDL_CloseAudioDevice(sdlAudioDevice);
|
||||
sdlAudioDevice = 0;
|
||||
}
|
||||
|
||||
JA_Music_t *JA_LoadMusic(Uint8* buffer, Uint32 length, const char* filename)
|
||||
{
|
||||
JA_Music_t *JA_LoadMusic(Uint8 *buffer, Uint32 length, const char *filename) {
|
||||
JA_Music_t *music = new JA_Music_t();
|
||||
|
||||
int chan, samplerate;
|
||||
@@ -190,8 +175,7 @@ JA_Music_t *JA_LoadMusic(Uint8* buffer, Uint32 length, const char* filename)
|
||||
return music;
|
||||
}
|
||||
|
||||
JA_Music_t *JA_LoadMusic(const char* filename)
|
||||
{
|
||||
JA_Music_t *JA_LoadMusic(const char *filename) {
|
||||
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
|
||||
FILE *f = fopen(filename, "rb");
|
||||
fseek(f, 0, SEEK_END);
|
||||
@@ -208,8 +192,7 @@ JA_Music_t *JA_LoadMusic(const char* filename)
|
||||
return music;
|
||||
}
|
||||
|
||||
void JA_PlayMusic(JA_Music_t *music, const int loop)
|
||||
{
|
||||
void JA_PlayMusic(JA_Music_t *music, const int loop) {
|
||||
if (!JA_musicEnabled) return;
|
||||
|
||||
JA_StopMusic();
|
||||
@@ -226,14 +209,12 @@ void JA_PlayMusic(JA_Music_t *music, const int loop)
|
||||
// SDL_ResumeAudioStreamDevice(current_music->stream);
|
||||
}
|
||||
|
||||
char *JA_GetMusicFilename(JA_Music_t *music)
|
||||
{
|
||||
char *JA_GetMusicFilename(JA_Music_t *music) {
|
||||
if (!music) music = current_music;
|
||||
return music->filename;
|
||||
}
|
||||
|
||||
void JA_PauseMusic()
|
||||
{
|
||||
void JA_PauseMusic() {
|
||||
if (!JA_musicEnabled) return;
|
||||
if (!current_music || current_music->state == JA_MUSIC_INVALID) return;
|
||||
|
||||
@@ -242,8 +223,7 @@ void JA_PauseMusic()
|
||||
SDL_UnbindAudioStream(current_music->stream);
|
||||
}
|
||||
|
||||
void JA_ResumeMusic()
|
||||
{
|
||||
void JA_ResumeMusic() {
|
||||
if (!JA_musicEnabled) return;
|
||||
if (!current_music || current_music->state == JA_MUSIC_INVALID) return;
|
||||
|
||||
@@ -252,8 +232,7 @@ void JA_ResumeMusic()
|
||||
SDL_BindAudioStream(sdlAudioDevice, current_music->stream);
|
||||
}
|
||||
|
||||
void JA_StopMusic()
|
||||
{
|
||||
void JA_StopMusic() {
|
||||
if (!JA_musicEnabled) return;
|
||||
if (!current_music || current_music->state == JA_MUSIC_INVALID) return;
|
||||
|
||||
@@ -266,8 +245,7 @@ void JA_StopMusic()
|
||||
current_music->filename = nullptr;
|
||||
}
|
||||
|
||||
void JA_FadeOutMusic(const int milliseconds)
|
||||
{
|
||||
void JA_FadeOutMusic(const int milliseconds) {
|
||||
if (!JA_musicEnabled) return;
|
||||
if (current_music == NULL || current_music->state == JA_MUSIC_INVALID) return;
|
||||
|
||||
@@ -277,78 +255,64 @@ void JA_FadeOutMusic(const int milliseconds)
|
||||
fade_initial_volume = JA_musicVolume;
|
||||
}
|
||||
|
||||
JA_Music_state JA_GetMusicState()
|
||||
{
|
||||
JA_Music_state JA_GetMusicState() {
|
||||
if (!JA_musicEnabled) return JA_MUSIC_DISABLED;
|
||||
if (!current_music) return JA_MUSIC_INVALID;
|
||||
|
||||
return current_music->state;
|
||||
}
|
||||
|
||||
void JA_DeleteMusic(JA_Music_t *music)
|
||||
{
|
||||
void JA_DeleteMusic(JA_Music_t *music) {
|
||||
if (current_music == music) current_music = nullptr;
|
||||
SDL_free(music->buffer);
|
||||
if (music->stream) SDL_DestroyAudioStream(music->stream);
|
||||
delete music;
|
||||
}
|
||||
|
||||
float JA_SetMusicVolume(float volume)
|
||||
{
|
||||
float JA_SetMusicVolume(float volume) {
|
||||
JA_musicVolume = SDL_clamp(volume, 0.0f, 1.0f);
|
||||
if (current_music) SDL_SetAudioStreamGain(current_music->stream, JA_musicVolume);
|
||||
return JA_musicVolume;
|
||||
}
|
||||
|
||||
void JA_SetMusicPosition(float value)
|
||||
{
|
||||
void JA_SetMusicPosition(float value) {
|
||||
if (!current_music) return;
|
||||
current_music->pos = value * current_music->spec.freq;
|
||||
}
|
||||
|
||||
float JA_GetMusicPosition()
|
||||
{
|
||||
float JA_GetMusicPosition() {
|
||||
if (!current_music) return 0;
|
||||
return float(current_music->pos) / float(current_music->spec.freq);
|
||||
}
|
||||
|
||||
void JA_EnableMusic(const bool value)
|
||||
{
|
||||
void JA_EnableMusic(const bool value) {
|
||||
if (!value && current_music && (current_music->state == JA_MUSIC_PLAYING)) JA_StopMusic();
|
||||
|
||||
JA_musicEnabled = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length)
|
||||
{
|
||||
JA_Sound_t *JA_NewSound(Uint8 *buffer, Uint32 length) {
|
||||
JA_Sound_t *sound = new JA_Sound_t();
|
||||
sound->buffer = buffer;
|
||||
sound->length = length;
|
||||
return sound;
|
||||
}
|
||||
|
||||
JA_Sound_t *JA_LoadSound(uint8_t* buffer, uint32_t size)
|
||||
{
|
||||
JA_Sound_t *JA_LoadSound(uint8_t *buffer, uint32_t size) {
|
||||
JA_Sound_t *sound = new JA_Sound_t();
|
||||
SDL_LoadWAV_IO(SDL_IOFromMem(buffer, size), 1, &sound->spec, &sound->buffer, &sound->length);
|
||||
|
||||
return sound;
|
||||
}
|
||||
|
||||
JA_Sound_t *JA_LoadSound(const char* filename)
|
||||
{
|
||||
JA_Sound_t *JA_LoadSound(const char *filename) {
|
||||
JA_Sound_t *sound = new JA_Sound_t();
|
||||
SDL_LoadWAV(filename, &sound->spec, &sound->buffer, &sound->length);
|
||||
|
||||
return sound;
|
||||
}
|
||||
|
||||
int JA_PlaySound(JA_Sound_t *sound, const int loop)
|
||||
{
|
||||
int JA_PlaySound(JA_Sound_t *sound, const int loop) {
|
||||
if (!JA_soundEnabled) return -1;
|
||||
|
||||
int channel = 0;
|
||||
@@ -368,8 +332,7 @@ int JA_PlaySound(JA_Sound_t *sound, const int loop)
|
||||
return channel;
|
||||
}
|
||||
|
||||
int JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop)
|
||||
{
|
||||
int JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop) {
|
||||
if (!JA_soundEnabled) return -1;
|
||||
|
||||
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return -1;
|
||||
@@ -387,8 +350,7 @@ int JA_PlaySoundOnChannel(JA_Sound_t *sound, const int channel, const int loop)
|
||||
return channel;
|
||||
}
|
||||
|
||||
void JA_DeleteSound(JA_Sound_t *sound)
|
||||
{
|
||||
void JA_DeleteSound(JA_Sound_t *sound) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
||||
if (channels[i].sound == sound) JA_StopChannel(i);
|
||||
}
|
||||
@@ -396,24 +358,18 @@ void JA_DeleteSound(JA_Sound_t *sound)
|
||||
delete sound;
|
||||
}
|
||||
|
||||
void JA_PauseChannel(const int channel)
|
||||
{
|
||||
void JA_PauseChannel(const int channel) {
|
||||
if (!JA_soundEnabled) return;
|
||||
|
||||
if (channel == -1)
|
||||
{
|
||||
if (channel == -1) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
|
||||
if (channels[i].state == JA_CHANNEL_PLAYING)
|
||||
{
|
||||
if (channels[i].state == JA_CHANNEL_PLAYING) {
|
||||
channels[i].state = JA_CHANNEL_PAUSED;
|
||||
// SDL_PauseAudioStreamDevice(channels[i].stream);
|
||||
SDL_UnbindAudioStream(channels[i].stream);
|
||||
}
|
||||
}
|
||||
else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS)
|
||||
{
|
||||
if (channels[channel].state == JA_CHANNEL_PLAYING)
|
||||
{
|
||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
||||
if (channels[channel].state == JA_CHANNEL_PLAYING) {
|
||||
channels[channel].state = JA_CHANNEL_PAUSED;
|
||||
// SDL_PauseAudioStreamDevice(channels[channel].stream);
|
||||
SDL_UnbindAudioStream(channels[channel].stream);
|
||||
@@ -421,24 +377,18 @@ void JA_PauseChannel(const int channel)
|
||||
}
|
||||
}
|
||||
|
||||
void JA_ResumeChannel(const int channel)
|
||||
{
|
||||
void JA_ResumeChannel(const int channel) {
|
||||
if (!JA_soundEnabled) return;
|
||||
|
||||
if (channel == -1)
|
||||
{
|
||||
if (channel == -1) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
|
||||
if (channels[i].state == JA_CHANNEL_PAUSED)
|
||||
{
|
||||
if (channels[i].state == JA_CHANNEL_PAUSED) {
|
||||
channels[i].state = JA_CHANNEL_PLAYING;
|
||||
// SDL_ResumeAudioStreamDevice(channels[i].stream);
|
||||
SDL_BindAudioStream(sdlAudioDevice, channels[i].stream);
|
||||
}
|
||||
}
|
||||
else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS)
|
||||
{
|
||||
if (channels[channel].state == JA_CHANNEL_PAUSED)
|
||||
{
|
||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
||||
if (channels[channel].state == JA_CHANNEL_PAUSED) {
|
||||
channels[channel].state = JA_CHANNEL_PLAYING;
|
||||
// SDL_ResumeAudioStreamDevice(channels[channel].stream);
|
||||
SDL_BindAudioStream(sdlAudioDevice, channels[channel].stream);
|
||||
@@ -446,12 +396,10 @@ void JA_ResumeChannel(const int channel)
|
||||
}
|
||||
}
|
||||
|
||||
void JA_StopChannel(const int channel)
|
||||
{
|
||||
void JA_StopChannel(const int channel) {
|
||||
if (!JA_soundEnabled) return;
|
||||
|
||||
if (channel == -1)
|
||||
{
|
||||
if (channel == -1) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
||||
if (channels[i].state != JA_CHANNEL_FREE) SDL_DestroyAudioStream(channels[i].stream);
|
||||
channels[i].stream = nullptr;
|
||||
@@ -459,9 +407,7 @@ void JA_StopChannel(const int channel)
|
||||
channels[i].pos = 0;
|
||||
channels[i].sound = NULL;
|
||||
}
|
||||
}
|
||||
else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS)
|
||||
{
|
||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
||||
if (channels[channel].state != JA_CHANNEL_FREE) SDL_DestroyAudioStream(channels[channel].stream);
|
||||
channels[channel].stream = nullptr;
|
||||
channels[channel].state = JA_CHANNEL_FREE;
|
||||
@@ -470,8 +416,7 @@ void JA_StopChannel(const int channel)
|
||||
}
|
||||
}
|
||||
|
||||
JA_Channel_state JA_GetChannelState(const int channel)
|
||||
{
|
||||
JA_Channel_state JA_GetChannelState(const int channel) {
|
||||
if (!JA_soundEnabled) return JA_SOUND_DISABLED;
|
||||
|
||||
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return JA_CHANNEL_INVALID;
|
||||
@@ -479,8 +424,7 @@ JA_Channel_state JA_GetChannelState(const int channel)
|
||||
return channels[channel].state;
|
||||
}
|
||||
|
||||
float JA_SetSoundVolume(float volume)
|
||||
{
|
||||
float JA_SetSoundVolume(float volume) {
|
||||
JA_soundVolume = SDL_clamp(volume, 0.0f, 1.0f);
|
||||
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
|
||||
@@ -490,17 +434,14 @@ float JA_SetSoundVolume(float volume)
|
||||
return JA_soundVolume;
|
||||
}
|
||||
|
||||
void JA_EnableSound(const bool value)
|
||||
{
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
|
||||
{
|
||||
void JA_EnableSound(const bool value) {
|
||||
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
|
||||
if (channels[i].state == JA_CHANNEL_PLAYING) JA_StopChannel(i);
|
||||
}
|
||||
JA_soundEnabled = value;
|
||||
}
|
||||
|
||||
float JA_SetVolume(float volume)
|
||||
{
|
||||
float JA_SetVolume(float volume) {
|
||||
JA_SetSoundVolume(JA_SetMusicVolume(volume) / 2.0f);
|
||||
|
||||
return JA_musicVolume;
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
#pragma once
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED, JA_SOUND_DISABLED };
|
||||
enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED, JA_MUSIC_DISABLED };
|
||||
enum JA_Channel_state { JA_CHANNEL_INVALID,
|
||||
JA_CHANNEL_FREE,
|
||||
JA_CHANNEL_PLAYING,
|
||||
JA_CHANNEL_PAUSED,
|
||||
JA_SOUND_DISABLED };
|
||||
enum JA_Music_state { JA_MUSIC_INVALID,
|
||||
JA_MUSIC_PLAYING,
|
||||
JA_MUSIC_PAUSED,
|
||||
JA_MUSIC_STOPPED,
|
||||
JA_MUSIC_DISABLED };
|
||||
|
||||
struct JA_Sound_t;
|
||||
struct JA_Music_t;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "core/jdraw8.hpp"
|
||||
#include "core/jfile.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include "external/gif.h"
|
||||
|
||||
#include "core/jfile.hpp"
|
||||
#include "core/jshader.hpp"
|
||||
#include "external/gif.h"
|
||||
|
||||
#define SCREEN_WIDTH 960
|
||||
#define SCREEN_HEIGHT 720
|
||||
@@ -212,9 +214,18 @@ void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) {
|
||||
void JD8_FadeOut() {
|
||||
for (int j = 0; j < 32; j++) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if( main_palette[i].r >= 8 ) main_palette[i].r-=8; else main_palette[i].r=0;
|
||||
if( main_palette[i].g >= 8 ) main_palette[i].g-=8; else main_palette[i].g=0;
|
||||
if( main_palette[i].b >= 8 ) main_palette[i].b-=8; else main_palette[i].b=0;
|
||||
if (main_palette[i].r >= 8)
|
||||
main_palette[i].r -= 8;
|
||||
else
|
||||
main_palette[i].r = 0;
|
||||
if (main_palette[i].g >= 8)
|
||||
main_palette[i].g -= 8;
|
||||
else
|
||||
main_palette[i].g = 0;
|
||||
if (main_palette[i].b >= 8)
|
||||
main_palette[i].b -= 8;
|
||||
else
|
||||
main_palette[i].b = 0;
|
||||
}
|
||||
JD8_Flip();
|
||||
}
|
||||
@@ -225,9 +236,18 @@ void JD8_FadeOut() {
|
||||
void JD8_FadeToPal(JD8_Palette pal) {
|
||||
for (int j = 0; j < 32; j++) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if( main_palette[i].r <= int(pal[i].r)-8 ) main_palette[i].r+=8; else main_palette[i].r=pal[i].r;
|
||||
if( main_palette[i].g <= int(pal[i].g)-8 ) main_palette[i].g+=8; else main_palette[i].g=pal[i].g;
|
||||
if( main_palette[i].b <= int(pal[i].b)-8 ) main_palette[i].b+=8; else main_palette[i].b=pal[i].b;
|
||||
if (main_palette[i].r <= int(pal[i].r) - 8)
|
||||
main_palette[i].r += 8;
|
||||
else
|
||||
main_palette[i].r = pal[i].r;
|
||||
if (main_palette[i].g <= int(pal[i].g) - 8)
|
||||
main_palette[i].g += 8;
|
||||
else
|
||||
main_palette[i].g = pal[i].g;
|
||||
if (main_palette[i].b <= int(pal[i].b) - 8)
|
||||
main_palette[i].b += 8;
|
||||
else
|
||||
main_palette[i].b = pal[i].b;
|
||||
}
|
||||
JD8_Flip();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#include "core/jfile.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "core/jfile.hpp"
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -19,8 +21,7 @@
|
||||
#define DEFAULT_FOLDER "data/"
|
||||
#define CONFIG_FILENAME "config.txt"
|
||||
|
||||
struct file_t
|
||||
{
|
||||
struct file_t {
|
||||
std::string path;
|
||||
uint32_t size;
|
||||
uint32_t offset;
|
||||
@@ -69,8 +70,7 @@ bool file_getdictionary() {
|
||||
fi.read((char *)&toc_offset, 4);
|
||||
fi.seekg(toc_offset);
|
||||
|
||||
for (uint32_t i=0; i<num_files; ++i)
|
||||
{
|
||||
for (uint32_t i = 0; i < num_files; ++i) {
|
||||
uint32_t file_offset, file_size;
|
||||
fi.read((char *)&file_offset, 4);
|
||||
fi.read((char *)&file_size, 4);
|
||||
@@ -93,7 +93,6 @@ char *file_getfilenamewithfolder(const char* filename) {
|
||||
}
|
||||
|
||||
FILE *file_getfilepointer(const char *resourcename, int &filesize, const bool binary) {
|
||||
|
||||
if (file_source == SOURCE_FILE and toc.size() == 0) {
|
||||
if (not file_getdictionary()) file_setsource(SOURCE_FOLDER);
|
||||
}
|
||||
@@ -141,8 +140,7 @@ char *file_getfilebuffer(const char *resourcename, int& filesize, const bool zer
|
||||
|
||||
// Crea la carpeta del sistema donde guardar datos.
|
||||
// Acepta rutas con subdirectorios (ej: "jailgames/aee") y crea toda la jerarquía.
|
||||
void file_setconfigfolder(const char *foldername)
|
||||
{
|
||||
void file_setconfigfolder(const char *foldername) {
|
||||
#ifdef _WIN32
|
||||
config_folder = std::string(getenv("APPDATA")) + "/" + foldername;
|
||||
#elif __APPLE__
|
||||
@@ -174,7 +172,8 @@ void file_loadconfigvalues() {
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
char *value = strchr(line, '=');
|
||||
if (value) {
|
||||
*value='\0'; value++;
|
||||
*value = '\0';
|
||||
value++;
|
||||
value[strlen(value) - 1] = '\0';
|
||||
config.push_back({line, value});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ Uint32 updateTime = 0;
|
||||
Uint32 cycle_counter = 0;
|
||||
|
||||
void JG_Init() {
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
||||
// SDL_WM_SetCaption( title, NULL );
|
||||
updateTime = SDL_GetTicks();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "core/jinput.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
const bool* keystates; // = SDL_GetKeyboardState( NULL );
|
||||
SDL_Event event;
|
||||
Uint8 cheat[5];
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#include <iostream>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "CoreFoundation/CoreFoundation.h"
|
||||
#include <OpenGL/OpenGL.h>
|
||||
|
||||
#include "CoreFoundation/CoreFoundation.h"
|
||||
|
||||
#if ESSENTIAL_GL_PRACTICES_SUPPORT_GL3
|
||||
#include <OpenGL/gl3.h>
|
||||
#else
|
||||
@@ -16,8 +17,7 @@
|
||||
#include <SDL3/SDL_opengl_glext.h>
|
||||
#endif
|
||||
|
||||
namespace shader
|
||||
{
|
||||
namespace shader {
|
||||
SDL_Window* win = nullptr;
|
||||
SDL_Renderer* renderer = nullptr;
|
||||
GLuint programId = 0;
|
||||
@@ -82,13 +82,11 @@ namespace shader
|
||||
// Check vertex shader for errors
|
||||
GLint shaderCompiled = GL_FALSE;
|
||||
glGetShaderiv(result, GL_COMPILE_STATUS, &shaderCompiled);
|
||||
if (shaderCompiled != GL_TRUE)
|
||||
{
|
||||
if (shaderCompiled != GL_TRUE) {
|
||||
std::cout << "Error en la compilación: " << result << "!" << std::endl;
|
||||
GLint logLength;
|
||||
glGetShaderiv(result, GL_INFO_LOG_LENGTH, &logLength);
|
||||
if (logLength > 0)
|
||||
{
|
||||
if (logLength > 0) {
|
||||
GLchar* log = (GLchar*)malloc(logLength);
|
||||
glGetShaderInfoLog(result, logLength, &logLength, log);
|
||||
std::cout << "Shader compile log:" << log << std::endl;
|
||||
@@ -100,8 +98,7 @@ namespace shader
|
||||
return result;
|
||||
}
|
||||
|
||||
GLuint compileProgram(const char* vertexShaderSource, const char* fragmentShaderSource)
|
||||
{
|
||||
GLuint compileProgram(const char* vertexShaderSource, const char* fragmentShaderSource) {
|
||||
GLuint programId = 0;
|
||||
GLuint vtxShaderId, fragShaderId;
|
||||
|
||||
@@ -110,8 +107,7 @@ namespace shader
|
||||
vtxShaderId = compileShader(vertexShaderSource, GL_VERTEX_SHADER);
|
||||
fragShaderId = compileShader(fragmentShaderSource ? fragmentShaderSource : vertexShaderSource, GL_FRAGMENT_SHADER);
|
||||
|
||||
if(vtxShaderId && fragShaderId)
|
||||
{
|
||||
if (vtxShaderId && fragShaderId) {
|
||||
// Associate shader with program
|
||||
glAttachShader(programId, vtxShaderId);
|
||||
glAttachShader(programId, fragShaderId);
|
||||
@@ -121,12 +117,12 @@ namespace shader
|
||||
// Check the status of the compile/link
|
||||
GLint logLen;
|
||||
glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &logLen);
|
||||
if (logLen > 0)
|
||||
{
|
||||
if (logLen > 0) {
|
||||
char* log = (char*)malloc(logLen * sizeof(char));
|
||||
// Show any errors as appropriate
|
||||
glGetProgramInfoLog(programId, logLen, &logLen, log);
|
||||
std::cout << "Prog Info Log: " << std::endl << log << std::endl;
|
||||
std::cout << "Prog Info Log: " << std::endl
|
||||
<< log << std::endl;
|
||||
free(log);
|
||||
}
|
||||
}
|
||||
@@ -135,8 +131,7 @@ namespace shader
|
||||
return programId;
|
||||
}
|
||||
|
||||
const bool init(SDL_Window* win, SDL_Texture* backBuffer, const char* vertexShader, const char* fragmentShader)
|
||||
{
|
||||
const bool init(SDL_Window* win, SDL_Texture* backBuffer, const char* vertexShader, const char* fragmentShader) {
|
||||
shader::win = win;
|
||||
shader::renderer = SDL_GetRenderer(win);
|
||||
shader::backBuffer = backBuffer;
|
||||
@@ -150,8 +145,7 @@ namespace shader
|
||||
nose = SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER, -1);
|
||||
printf("texture target number: %i\n", nose);
|
||||
|
||||
if (access != SDL_TEXTUREACCESS_TARGET)
|
||||
{
|
||||
if (access != SDL_TEXTUREACCESS_TARGET) {
|
||||
std::cout << "ERROR FATAL: La textura per al render ha de tindre SDL_TEXTUREACCESS_TARGET definit." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
@@ -180,19 +174,16 @@ namespace shader
|
||||
|
||||
unsigned char pixels[512 * 240 * 4];
|
||||
|
||||
void render()
|
||||
{
|
||||
void render() {
|
||||
SDL_FlushRenderer(renderer);
|
||||
SDL_SetRenderTarget(renderer, NULL);
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_FlushRenderer(renderer);
|
||||
|
||||
if (usingOpenGL)
|
||||
{
|
||||
if (usingOpenGL) {
|
||||
GLint oldProgramId;
|
||||
if (programId != 0)
|
||||
{
|
||||
if (programId != 0) {
|
||||
glGetIntegerv(GL_CURRENT_PROGRAM, &oldProgramId);
|
||||
glUseProgram(programId);
|
||||
}
|
||||
@@ -226,6 +217,9 @@ namespace shader
|
||||
SDL_RenderTexture(renderer, backBuffer, NULL, NULL);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
if (glGetError()) { printf("GLERROR!\n"); exit(1); }
|
||||
if (glGetError()) {
|
||||
printf("GLERROR!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} // namespace shader
|
||||
|
||||
@@ -35,10 +35,8 @@
|
||||
// Ah! una cosa mes: al compilar, en Linux afegir "-lGL", en Windows afegir "-lopengl32".
|
||||
// En Mac ni idea
|
||||
|
||||
namespace shader
|
||||
{
|
||||
const bool init(SDL_Window* win, SDL_Texture* backBuffer,
|
||||
const char* vertexShader, const char* fragmentShader=nullptr);
|
||||
namespace shader {
|
||||
const bool init(SDL_Window* win, SDL_Texture* backBuffer, const char* vertexShader, const char* fragmentShader = nullptr);
|
||||
|
||||
void render();
|
||||
}
|
||||
} // namespace shader
|
||||
|
||||
2
source/external/.clang-format
vendored
Normal file
2
source/external/.clang-format
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
DisableFormat: true
|
||||
SortIncludes: Never
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "game/bola.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
Bola::Bola( JD8_Surface gfx, Prota* sam ) : Sprite( gfx ) {
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
Bola::Bola(JD8_Surface gfx, Prota* sam)
|
||||
: Sprite(gfx) {
|
||||
this->sam = sam;
|
||||
|
||||
this->entitat = (Entitat*)malloc(sizeof(Entitat));
|
||||
@@ -32,17 +35,13 @@ Bola::Bola( JD8_Surface gfx, Prota* sam ) : Sprite( gfx ) {
|
||||
this->x = 20;
|
||||
this->y = 100;
|
||||
this->contador = 0;
|
||||
|
||||
}
|
||||
|
||||
void Bola::draw() {
|
||||
|
||||
if (this->contador == 0) Sprite::draw();
|
||||
|
||||
}
|
||||
|
||||
void Bola::update() {
|
||||
|
||||
if (this->contador == 0) {
|
||||
// Augmentem la x
|
||||
this->x++;
|
||||
@@ -64,5 +63,4 @@ void Bola::update() {
|
||||
this->contador--;
|
||||
if (this->contador == 0) this->x = 20;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "game/sprite.hpp"
|
||||
#include "game/prota.hpp"
|
||||
#include "game/info.hpp"
|
||||
#include "game/prota.hpp"
|
||||
#include "game/sprite.hpp"
|
||||
|
||||
class Bola : public Sprite {
|
||||
|
||||
public:
|
||||
|
||||
Bola(JD8_Surface gfx, Prota* sam);
|
||||
|
||||
void draw();
|
||||
void update();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
Uint8 contador;
|
||||
Prota* sam;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "game/engendro.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
Engendro::Engendro( JD8_Surface gfx, Uint16 x, Uint16 y ) : Sprite( gfx ) {
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
Engendro::Engendro(JD8_Surface gfx, Uint16 x, Uint16 y)
|
||||
: Sprite(gfx) {
|
||||
this->entitat = (Entitat*)malloc(sizeof(Entitat));
|
||||
// Frames
|
||||
this->entitat->num_frames = 4;
|
||||
@@ -38,17 +40,13 @@ Engendro::Engendro( JD8_Surface gfx, Uint16 x, Uint16 y ) : Sprite( gfx ) {
|
||||
this->y = y;
|
||||
this->o = 0;
|
||||
this->cycles_per_frame = 30;
|
||||
|
||||
}
|
||||
|
||||
void Engendro::draw() {
|
||||
|
||||
Sprite::draw();
|
||||
|
||||
}
|
||||
|
||||
bool Engendro::update() {
|
||||
|
||||
bool mort = false;
|
||||
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 0) {
|
||||
@@ -57,7 +55,6 @@ bool Engendro::update() {
|
||||
this->vida--;
|
||||
}
|
||||
|
||||
|
||||
if (vida == 0) mort = true;
|
||||
|
||||
return mort;
|
||||
|
||||
@@ -3,16 +3,12 @@
|
||||
#include "game/sprite.hpp"
|
||||
|
||||
class Engendro : public Sprite {
|
||||
|
||||
public:
|
||||
|
||||
Engendro(JD8_Surface gfx, Uint16 x, Uint16 y);
|
||||
|
||||
void draw();
|
||||
bool update();
|
||||
|
||||
protected:
|
||||
|
||||
Uint8 vida;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "game/info.hpp"
|
||||
|
||||
namespace info
|
||||
{
|
||||
namespace info {
|
||||
int num_piramide;
|
||||
int num_habitacio;
|
||||
int diners;
|
||||
@@ -11,4 +10,4 @@ namespace info
|
||||
int engendros;
|
||||
bool nou_personatge;
|
||||
bool pepe_activat;
|
||||
};
|
||||
}; // namespace info
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace info
|
||||
{
|
||||
namespace info {
|
||||
extern int num_piramide;
|
||||
extern int num_habitacio;
|
||||
extern int diners;
|
||||
@@ -11,4 +10,4 @@ namespace info
|
||||
extern int engendros;
|
||||
extern bool nou_personatge;
|
||||
extern bool pepe_activat;
|
||||
};
|
||||
}; // namespace info
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "game/mapa.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jinput.hpp"
|
||||
#include <stdlib.h>
|
||||
|
||||
Mapa::Mapa(JD8_Surface gfx, Prota* sam) {
|
||||
|
||||
this->gfx = gfx;
|
||||
this->sam = sam;
|
||||
|
||||
@@ -19,17 +19,13 @@ Mapa::Mapa( JD8_Surface gfx, Prota* sam ) {
|
||||
this->clau = false;
|
||||
this->porta_oberta = false;
|
||||
this->nova_momia = false;
|
||||
|
||||
}
|
||||
|
||||
Mapa::~Mapa(void) {
|
||||
|
||||
JD8_FreeSurface(this->fondo);
|
||||
|
||||
}
|
||||
|
||||
void Mapa::draw() {
|
||||
|
||||
if (info::num_piramide != 4) {
|
||||
switch (sam->o) {
|
||||
case 0: // Down
|
||||
@@ -60,11 +56,9 @@ void Mapa::draw() {
|
||||
JD8_BlitCK(95, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
JD8_BlitCK(195, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
JD8_BlitCK(245, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
|
||||
};
|
||||
|
||||
void Mapa::update() {
|
||||
|
||||
if (((sam->x - 20) % 65 == 0) && ((sam->y - 30) % 35 == 0) && ((this->ultim_vertex.columna != (sam->x - 20) / 65) || (this->ultim_vertex.fila != (sam->y - 30) / 35))) {
|
||||
this->vertex.columna = (sam->x - 20) / 65;
|
||||
this->vertex.fila = (sam->y - 30) / 35;
|
||||
@@ -83,7 +77,6 @@ void Mapa::update() {
|
||||
this->frame_torxes++;
|
||||
this->frame_torxes = this->frame_torxes % 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool Mapa::novaMomia() {
|
||||
@@ -93,13 +86,11 @@ bool Mapa::novaMomia() {
|
||||
}
|
||||
|
||||
void Mapa::preparaFondoEstatic() {
|
||||
|
||||
// Prepara el fondo est<73>tic de l'habitaci<63>
|
||||
this->fondo = JD8_NewSurface();
|
||||
if (info::num_piramide == 6) {
|
||||
JD8_BlitToSurface(9, 2, this->gfx, 227, 185, 92, 7, this->fondo); // Text "SECRETA"
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
JD8_BlitToSurface(9, 2, this->gfx, 60, 185, 39, 7, this->fondo); // Text "NIVELL"
|
||||
JD8_BlitToSurface(72, 6, this->gfx, 153, 189, 3, 1, this->fondo); // Ralleta entre num piramide i num habitacio
|
||||
}
|
||||
@@ -133,7 +124,6 @@ void Mapa::preparaFondoEstatic() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pinta vores de les parets
|
||||
JD8_BlitCKToSurface(5, 15, this->gfx, 30, 110, 15, 15, this->fondo, 255);
|
||||
JD8_BlitCKToSurface(295, 15, this->gfx, 45, 110, 15, 15, this->fondo, 255);
|
||||
@@ -197,7 +187,6 @@ Uint8 minim( Uint8 a, Uint8 b ) {
|
||||
}
|
||||
|
||||
void Mapa::comprovaUltimCami() {
|
||||
|
||||
Uint8 col_aux = abs(this->vertex.columna - this->ultim_vertex.columna);
|
||||
Uint8 fil_aux = abs(this->vertex.fila - this->ultim_vertex.fila);
|
||||
|
||||
@@ -234,20 +223,19 @@ void Mapa::comprovaUltimCami() {
|
||||
}
|
||||
}
|
||||
|
||||
void Mapa::comprovaCaixa( Uint8 num )
|
||||
{
|
||||
void Mapa::comprovaCaixa(Uint8 num) {
|
||||
// Si la tomba ja està oberta, no hi ha res que mirar
|
||||
if (this->tombes[num].oberta) return;
|
||||
|
||||
// Si algun costat encara no està passat, no hi ha res que fer
|
||||
for( int i = 0; i < 4; i++ ) if( !this->tombes[num].costat[i] ) return;
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (!this->tombes[num].costat[i]) return;
|
||||
|
||||
// Sinó, pos la acabem d'obrir
|
||||
this->tombes[num].oberta = true;
|
||||
|
||||
// Comprobem el premi del kinder sorpresa
|
||||
switch( this->tombes[num].contingut )
|
||||
{
|
||||
switch (this->tombes[num].contingut) {
|
||||
case CONTE_RES:
|
||||
this->tombes[num].x = 50;
|
||||
break;
|
||||
@@ -283,10 +271,8 @@ void Mapa::comprovaCaixa( Uint8 num )
|
||||
}
|
||||
|
||||
void Mapa::comprovaPorta() {
|
||||
|
||||
if (this->clau && this->farao) {
|
||||
JD8_BlitCKToSurface(150, 18, this->gfx, 15, 143, 15, 12, this->fondo, 255);
|
||||
porta_oberta = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/jdraw8.hpp"
|
||||
|
||||
#include "game/info.hpp"
|
||||
#include "game/prota.hpp"
|
||||
|
||||
@@ -27,9 +26,7 @@ struct Vertex {
|
||||
};
|
||||
|
||||
class Mapa {
|
||||
|
||||
public:
|
||||
|
||||
Mapa(JD8_Surface gfx, Prota* sam);
|
||||
~Mapa(void);
|
||||
|
||||
@@ -41,7 +38,6 @@ public:
|
||||
Tomba tombes[16];
|
||||
|
||||
protected:
|
||||
|
||||
void preparaFondoEstatic();
|
||||
void preparaTombes();
|
||||
|
||||
@@ -60,5 +56,4 @@ protected:
|
||||
bool clau;
|
||||
bool porta_oberta;
|
||||
bool nova_momia;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "game/marcador.hpp"
|
||||
|
||||
Marcador::Marcador(JD8_Surface gfx, Prota* sam) {
|
||||
|
||||
this->gfx = gfx;
|
||||
this->sam = sam;
|
||||
}
|
||||
@@ -10,7 +9,6 @@ Marcador::~Marcador(void) {
|
||||
}
|
||||
|
||||
void Marcador::draw() {
|
||||
|
||||
if (info::num_piramide < 6) {
|
||||
this->pintaNumero(55, 2, info::num_piramide);
|
||||
this->pintaNumero(80, 2, info::num_habitacio);
|
||||
|
||||
@@ -5,19 +5,15 @@
|
||||
#include "game/prota.hpp"
|
||||
|
||||
class Marcador {
|
||||
|
||||
public:
|
||||
|
||||
Marcador(JD8_Surface gfx, Prota* sam);
|
||||
~Marcador(void);
|
||||
|
||||
void draw();
|
||||
|
||||
protected:
|
||||
|
||||
void pintaNumero(Uint16 x, Uint16 y, Uint8 num);
|
||||
|
||||
JD8_Surface gfx;
|
||||
Prota* sam;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#include "game/modulegame.hpp"
|
||||
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jdraw8.hpp"
|
||||
#include "core/jail_audio.hpp"
|
||||
#include "core/jinput.hpp"
|
||||
#include "core/jdraw8.hpp"
|
||||
#include "core/jfile.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jinput.hpp"
|
||||
|
||||
ModuleGame::ModuleGame() {
|
||||
|
||||
this->gfx = JD8_LoadSurface(info::pepe_activat ? "frames2.gif" : "frames.gif");
|
||||
JG_SetUpdateTicks(10);
|
||||
|
||||
@@ -23,11 +22,9 @@ ModuleGame::ModuleGame() {
|
||||
|
||||
this->final = 0;
|
||||
this->iniciarMomies();
|
||||
|
||||
}
|
||||
|
||||
ModuleGame::~ModuleGame(void) {
|
||||
|
||||
JD8_FadeOut();
|
||||
|
||||
if (this->bola != NULL) delete this->bola;
|
||||
@@ -40,11 +37,9 @@ ModuleGame::~ModuleGame(void) {
|
||||
delete this->sam;
|
||||
|
||||
JD8_FreeSurface(this->gfx);
|
||||
|
||||
}
|
||||
|
||||
int ModuleGame::Go() {
|
||||
|
||||
this->Draw();
|
||||
|
||||
const char* music = info::num_piramide == 3 ? "00000008.ogg" : (info::num_piramide == 2 ? "00000007.ogg" : (info::num_piramide == 6 ? "00000002.ogg" : "00000006.ogg"));
|
||||
@@ -58,7 +53,6 @@ int ModuleGame::Go() {
|
||||
JD8_FadeToPal(JD8_LoadPalette(info::pepe_activat ? "frames2.gif" : "frames.gif"));
|
||||
|
||||
while (this->final == 0 && !JG_Quitting()) {
|
||||
|
||||
this->Draw();
|
||||
this->Update();
|
||||
}
|
||||
@@ -88,7 +82,6 @@ int ModuleGame::Go() {
|
||||
}
|
||||
|
||||
void ModuleGame::Draw() {
|
||||
|
||||
this->mapa->draw();
|
||||
this->marcador->draw();
|
||||
this->sam->draw();
|
||||
@@ -147,8 +140,11 @@ void ModuleGame::Update() {
|
||||
}
|
||||
|
||||
void ModuleGame::iniciarMomies() {
|
||||
|
||||
if( info::num_habitacio == 1 ) { info::momies = 1; } else { info::momies++; }
|
||||
if (info::num_habitacio == 1) {
|
||||
info::momies = 1;
|
||||
} else {
|
||||
info::momies++;
|
||||
}
|
||||
if (info::num_piramide == 6) info::momies = 8;
|
||||
|
||||
int x = 20;
|
||||
@@ -161,6 +157,9 @@ void ModuleGame::iniciarMomies() {
|
||||
this->momies->insertar(new Momia(this->gfx, dimonis, x, y, this->sam));
|
||||
}
|
||||
x += 65;
|
||||
if( x == 345 ) { x = 20; y -= 35; }
|
||||
if (x == 345) {
|
||||
x = 20;
|
||||
y -= 35;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "game/bola.hpp"
|
||||
#include "game/info.hpp"
|
||||
#include "game/mapa.hpp"
|
||||
#include "game/prota.hpp"
|
||||
#include "game/marcador.hpp"
|
||||
#include "game/momia.hpp"
|
||||
#include "game/bola.hpp"
|
||||
#include "game/prota.hpp"
|
||||
|
||||
class ModuleGame {
|
||||
|
||||
public:
|
||||
|
||||
ModuleGame();
|
||||
~ModuleGame(void);
|
||||
|
||||
int Go();
|
||||
|
||||
private:
|
||||
|
||||
void Draw();
|
||||
void Update();
|
||||
|
||||
@@ -31,5 +28,4 @@ private:
|
||||
Marcador* marcador;
|
||||
Momia* momies;
|
||||
Bola* bola;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#include "game/modulesequence.hpp"
|
||||
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jdraw8.hpp"
|
||||
#include "core/jinput.hpp"
|
||||
#include "core/jfile.hpp"
|
||||
#include "core/jail_audio.hpp"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "core/jail_audio.hpp"
|
||||
#include "core/jdraw8.hpp"
|
||||
#include "core/jfile.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jinput.hpp"
|
||||
|
||||
ModuleSequence::ModuleSequence() {
|
||||
}
|
||||
|
||||
@@ -15,7 +17,6 @@ ModuleSequence::~ModuleSequence(void) {
|
||||
}
|
||||
|
||||
int ModuleSequence::Go() {
|
||||
|
||||
if (info::num_piramide == 6 && info::diners < 200) info::num_piramide = 7;
|
||||
|
||||
switch (info::num_piramide) {
|
||||
@@ -71,17 +72,19 @@ int ModuleSequence::Go() {
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int minim(const int a, const int b) {
|
||||
if( b < a ) { return b; } else { return a; }
|
||||
if (b < a) {
|
||||
return b;
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
void play_music(const char *music, bool loop = -1)
|
||||
{
|
||||
void play_music(const char* music, bool loop = -1) {
|
||||
int size;
|
||||
char* buffer = file_getfilebuffer(music, size);
|
||||
JA_PlayMusic(JA_LoadMusic((Uint8*)buffer, size, music), loop);
|
||||
@@ -98,82 +101,178 @@ void ModuleSequence::doIntro() {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JG_SetUpdateTicks(100);
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 27, 45);
|
||||
JD8_Blit(68, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 53, 45);
|
||||
JD8_Blit(96, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 66, 45);
|
||||
JD8_Blit(109, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JG_SetUpdateTicks(200);
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 92, 45);
|
||||
JD8_Blit(136, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 92, 45);
|
||||
// JD8_Blit( 136, 78, gfx, 274, 155, 27, 45 );
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JG_SetUpdateTicks(100);
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 118, 45);
|
||||
JD8_Blit(160, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 145, 45);
|
||||
JD8_Blit(188, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 178, 45);
|
||||
JD8_Blit(221, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 205, 45);
|
||||
JD8_Blit(248, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JG_SetUpdateTicks(200);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
JD8_Blit(274, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
JD8_Blit(274, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
JD8_Blit(274, 78, gfx, 274, 155, 27, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 256; j++) {
|
||||
for (int i = 16; i < 32; i++) {
|
||||
@@ -190,7 +289,13 @@ void ModuleSequence::doIntro() {
|
||||
JD8_Flip();
|
||||
}
|
||||
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
JG_SetUpdateTicks(20);
|
||||
|
||||
Uint16 fr1 = 13;
|
||||
@@ -239,72 +344,96 @@ void ModuleSequence::doIntro() {
|
||||
|
||||
// camina cap a la DRETA }
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_1[(i div 5) mod fr1],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_1[(i / 5) % fr1], 0, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// trau el MAPA DRETA }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_3[minim((i div 5),fr3-1)],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[minim((i / 5), fr3 - 1)], 30, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// guarda el MAPA }
|
||||
|
||||
for (int i = 200; i >= 0; i--) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_3[minim((i div 5),fr3-1)],15,15,200,150);
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[minim((i / 5), fr3 - 1)], 30, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// camina cap a la ESQUERRA }
|
||||
|
||||
for (int i = 200; i >= 80; i--) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_2[(i div 5) mod fr2],15,15,i,150);
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_2[(i / 5) % fr2], 15, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// trau el MAPA ESQUERRA }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_4[minim((i div 5),fr4-1)],15,15,80,150);
|
||||
JD8_BlitCK(80, 150, gfx, fr_ani_4[minim((i / 5), fr4 - 1)], 45, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// momia cap a la ESQUERRA }
|
||||
|
||||
for (int i = 300; i >= 95; i--) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_6[(i div 10) mod fr6],15,15,i,150);
|
||||
@@ -313,13 +442,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(80, 150, gfx, fr_ani_4[fr4 - 1], 45, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// girar-se }
|
||||
|
||||
for (int i = 0; i <= 50; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_1[1],15,15,80,150);
|
||||
@@ -330,13 +464,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(80, 133, gfx, 0, interrogant, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bot de SUSTO }
|
||||
|
||||
for (int i = 0; i <= 49; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_5[minim((i div 5),fr5-1)],15,15,80,150-((i mod 50) div 5));
|
||||
@@ -345,13 +484,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bot de SUSTO }
|
||||
|
||||
for (int i = 50; i <= 99; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_5[minim((i div 5),fr5-1)],15,15,80,140+((i mod 50) div 5));
|
||||
@@ -360,13 +504,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// camina cap a la ESQUERRA }
|
||||
|
||||
for (int i = 80; i >= 0; i--) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_2[(i div 5) mod fr2],15,15,i,150);
|
||||
@@ -375,13 +524,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(95, 150, gfx, fr_ani_6[4], 60, 15, 15, 0);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// final }
|
||||
|
||||
for (int i = 0; i <= 150; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_6[4],15,15,95,150);
|
||||
@@ -393,12 +547,10 @@ void ModuleSequence::doIntro() {
|
||||
}
|
||||
//-----}
|
||||
|
||||
|
||||
break;
|
||||
case 1:
|
||||
// camina cap a la DRETA }
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
@@ -407,13 +559,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(i, 150, gfx, fr_ani_1[(i / 5) % fr1], 0, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// trau el MAPA DRETA }
|
||||
|
||||
for (int i = 0; i <= 300; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
@@ -422,13 +579,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[minim(i / 5, fr3 - 1)], 30, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// INTERROGANT }
|
||||
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
@@ -439,13 +601,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_3[fr3 - 1], 30, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// deixa caure el MAPA i SOMBRA }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
@@ -458,13 +625,18 @@ void ModuleSequence::doIntro() {
|
||||
}
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SOMBRA i PEDRA }
|
||||
|
||||
for (int i = 0; i <= 75; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
@@ -475,13 +647,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(200, i * 2, gfx, fr_ani_8[0], 75, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// trencar PEDRA }
|
||||
|
||||
for (int i = 0; i <= 19; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
@@ -490,13 +667,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(200, 150, gfx, fr_ani_8[i / 10], 75, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FINAL }
|
||||
|
||||
for (int i = 0; i <= 200; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,creu,15,15,200,155);
|
||||
@@ -509,13 +691,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(215, 150, gfx, fr_ani_8[3], 75, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// camina cap a la DRETA }
|
||||
for (int i = 0; i <= 145; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_1[(i div 5) mod fr1],15,15,i,150);
|
||||
@@ -524,13 +711,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(304 - i, 150, gfx, fr_ani_6[(i / 10) % fr6], 60, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// els dos quets }
|
||||
|
||||
for (int i = 0; i <= 100; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_1[1],15,15,145,150);
|
||||
@@ -539,13 +731,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(160, 150, gfx, fr_ani_6[1], 60, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// aparicio altaveu }
|
||||
|
||||
for (int i = 0; i <= 50; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_11[(i div 10) mod 2],15,15,125,150);
|
||||
@@ -556,13 +753,18 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(160, 150, gfx, fr_ani_6[1], 60, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// BALL }
|
||||
|
||||
for (int i = 0; i <= 800; i++) {
|
||||
|
||||
JD8_ClearScreen(0);
|
||||
JD8_Blit(43, 78, gfx, 43, 155, 231, 45);
|
||||
// Put_sprite(from,where,fr_ani_9[(i div 10) mod fr9],15,15,145,150);
|
||||
@@ -573,17 +775,21 @@ void ModuleSequence::doIntro() {
|
||||
JD8_BlitCK(125, 150, gfx, fr_ani_11[((i / 5) % 4) + 2], 90, 15, 15, 255);
|
||||
|
||||
JD8_Flip();
|
||||
while( !JG_ShouldUpdate() ) { JI_Update(); if( JI_AnyKey() || JG_Quitting() ) { JD8_FreeSurface( gfx ); return; } }
|
||||
while (!JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (JI_AnyKey() || JG_Quitting()) {
|
||||
JD8_FreeSurface(gfx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
JD8_FreeSurface(gfx);
|
||||
}
|
||||
|
||||
|
||||
void ModuleSequence::doMenu() {
|
||||
JG_SetUpdateTicks(20);
|
||||
JD8_Surface fondo = JD8_LoadSurface("menu.gif");
|
||||
@@ -603,7 +809,6 @@ void ModuleSequence::doMenu() {
|
||||
|
||||
JI_Update();
|
||||
while (!JI_AnyKey() && !JG_Quitting() && !JI_KeyPressed(SDL_SCANCODE_P)) {
|
||||
|
||||
JD8_Blit(0, 0, fondo, 0, 0, 320, 100); // fondo sol estatic
|
||||
|
||||
JD8_BlitCK(horitzo, 100, fondo, 0, 100, 320 - horitzo, 100, 255); // fondo moviment
|
||||
@@ -624,9 +829,18 @@ void ModuleSequence::doMenu() {
|
||||
JD8_Flip();
|
||||
|
||||
if (JG_ShouldUpdate()) {
|
||||
if( contador%4 == 0 ) { palmeres--; if( palmeres < 0 ) palmeres = 319; }
|
||||
if( contador%8 == 0 ) { camello++; if( camello == 4 ) camello = 0; }
|
||||
if( contador%16 == 0 ) { horitzo--; if( horitzo < 0 ) horitzo = 319; }
|
||||
if (contador % 4 == 0) {
|
||||
palmeres--;
|
||||
if (palmeres < 0) palmeres = 319;
|
||||
}
|
||||
if (contador % 8 == 0) {
|
||||
camello++;
|
||||
if (camello == 4) camello = 0;
|
||||
}
|
||||
if (contador % 16 == 0) {
|
||||
horitzo--;
|
||||
if (horitzo < 0) horitzo = 319;
|
||||
}
|
||||
contador++;
|
||||
JI_Update();
|
||||
}
|
||||
@@ -641,7 +855,6 @@ void ModuleSequence::doMenu() {
|
||||
void ModuleSequence::doSlides() {
|
||||
JG_SetUpdateTicks(20);
|
||||
|
||||
|
||||
const char* arxiu;
|
||||
if (info::num_piramide == 7) {
|
||||
play_music("00000005.ogg", 1);
|
||||
@@ -695,7 +908,10 @@ void ModuleSequence::doSlides() {
|
||||
case 4:
|
||||
case 7:
|
||||
contador--;
|
||||
if (contador == -150) { contador = 0; step++; }
|
||||
if (contador == -150) {
|
||||
contador = 0;
|
||||
step++;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
case 5:
|
||||
@@ -849,8 +1065,9 @@ void ModuleSequence::doSecreta() {
|
||||
}
|
||||
|
||||
void ModuleSequence::doCredits() {
|
||||
|
||||
struct { Uint16 x, y; } frames_coche[8] = { { 214, 152 }, { 214, 104 }, { 214, 56 }, { 214, 104 }, { 214, 152 }, { 214, 8 }, { 108, 152 }, { 214, 8 } };
|
||||
struct {
|
||||
Uint16 x, y;
|
||||
} frames_coche[8] = {{214, 152}, {214, 104}, {214, 56}, {214, 104}, {214, 152}, {214, 8}, {108, 152}, {214, 8}};
|
||||
const Uint32 n_frames_coche = 8;
|
||||
const Uint32 velocitat_coche = 3;
|
||||
|
||||
@@ -945,4 +1162,3 @@ void ModuleSequence::doMort() {
|
||||
}
|
||||
play_music("00000003.ogg");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,13 @@
|
||||
#include "game/info.hpp"
|
||||
|
||||
class ModuleSequence {
|
||||
|
||||
public:
|
||||
|
||||
ModuleSequence();
|
||||
~ModuleSequence(void);
|
||||
|
||||
int Go();
|
||||
|
||||
private:
|
||||
|
||||
void doIntro();
|
||||
void doMenu();
|
||||
void doSlides();
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "game/momia.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
Momia::Momia( JD8_Surface gfx, bool dimoni, Uint16 x, Uint16 y, Prota* sam ) : Sprite( gfx ) {
|
||||
#include "core/jgame.hpp"
|
||||
|
||||
Momia::Momia(JD8_Surface gfx, bool dimoni, Uint16 x, Uint16 y, Prota* sam)
|
||||
: Sprite(gfx) {
|
||||
this->dimoni = dimoni;
|
||||
this->sam = sam;
|
||||
|
||||
@@ -20,7 +23,6 @@ Momia::Momia( JD8_Surface gfx, bool dimoni, Uint16 x, Uint16 y, Prota* sam ) : S
|
||||
if (this->dimoni) this->entitat->frames[frame].x += 75;
|
||||
this->entitat->frames[frame].y = 20 + (y * 15);
|
||||
frame++;
|
||||
|
||||
}
|
||||
}
|
||||
// Animacions
|
||||
@@ -65,7 +67,6 @@ Momia::Momia( JD8_Surface gfx, bool dimoni, Uint16 x, Uint16 y, Prota* sam ) : S
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Momia::clear() {
|
||||
@@ -75,11 +76,9 @@ void Momia::clear() {
|
||||
}
|
||||
|
||||
void Momia::draw() {
|
||||
|
||||
if (this->engendro != NULL) {
|
||||
this->engendro->draw();
|
||||
} else {
|
||||
|
||||
Sprite::draw();
|
||||
|
||||
if (info::num_piramide == 4) {
|
||||
@@ -94,7 +93,6 @@ void Momia::draw() {
|
||||
}
|
||||
|
||||
bool Momia::update() {
|
||||
|
||||
bool morta = false;
|
||||
|
||||
if (this->engendro != NULL) {
|
||||
@@ -104,19 +102,28 @@ bool Momia::update() {
|
||||
}
|
||||
} else {
|
||||
if (this->sam->o < 4 && (this->dimoni || info::num_piramide == 5 || JG_GetCycleCounter() % 2 == 0)) {
|
||||
|
||||
if ((this->x - 20) % 65 == 0 && (this->y - 30) % 35 == 0) {
|
||||
if (this->dimoni) {
|
||||
if (rand() % 2 == 0) {
|
||||
if( this->x > this->sam->x ) { this->o = 3; }
|
||||
else if( this->x < this->sam->x ) { this->o = 2; }
|
||||
else if( this->y < this->sam->y ) { this->o = 0; }
|
||||
else if( this->y > this->sam->y ) { this->o = 1; }
|
||||
if (this->x > this->sam->x) {
|
||||
this->o = 3;
|
||||
} else if (this->x < this->sam->x) {
|
||||
this->o = 2;
|
||||
} else if (this->y < this->sam->y) {
|
||||
this->o = 0;
|
||||
} else if (this->y > this->sam->y) {
|
||||
this->o = 1;
|
||||
}
|
||||
} else {
|
||||
if( this->y < this->sam->y ) { this->o = 0; }
|
||||
else if( this->y > this->sam->y ) { this->o = 1; }
|
||||
else if( this->x > this->sam->x ) { this->o = 3; }
|
||||
else if( this->x < this->sam->x ) { this->o = 2; }
|
||||
if (this->y < this->sam->y) {
|
||||
this->o = 0;
|
||||
} else if (this->y > this->sam->y) {
|
||||
this->o = 1;
|
||||
} else if (this->x > this->sam->x) {
|
||||
this->o = 3;
|
||||
} else if (this->x < this->sam->x) {
|
||||
this->o = 2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this->o = rand() % 4;
|
||||
@@ -168,7 +175,6 @@ bool Momia::update() {
|
||||
}
|
||||
|
||||
void Momia::insertar(Momia* momia) {
|
||||
|
||||
if (this->next != NULL) {
|
||||
this->next->insertar(momia);
|
||||
} else {
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "game/sprite.hpp"
|
||||
#include "game/prota.hpp"
|
||||
#include "game/engendro.hpp"
|
||||
#include "game/info.hpp"
|
||||
#include "game/prota.hpp"
|
||||
#include "game/sprite.hpp"
|
||||
|
||||
class Momia : public Sprite {
|
||||
|
||||
public:
|
||||
|
||||
Momia(JD8_Surface gfx, bool dimoni, Uint16 x, Uint16 y, Prota* sam);
|
||||
|
||||
void clear();
|
||||
@@ -20,8 +18,6 @@ public:
|
||||
Momia* next;
|
||||
|
||||
protected:
|
||||
|
||||
Prota* sam;
|
||||
Engendro* engendro;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "game/prota.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jinput.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
Prota::Prota( JD8_Surface gfx ) : Sprite( gfx ) {
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jinput.hpp"
|
||||
|
||||
Prota::Prota(JD8_Surface gfx)
|
||||
: Sprite(gfx) {
|
||||
this->entitat = (Entitat*)malloc(sizeof(Entitat));
|
||||
this->entitat->num_frames = 82;
|
||||
this->entitat->frames = (Frame*)malloc(this->entitat->num_frames * sizeof(Frame));
|
||||
@@ -17,7 +19,6 @@ Prota::Prota( JD8_Surface gfx ) : Sprite( gfx ) {
|
||||
this->entitat->frames[frame].x = x * 15;
|
||||
this->entitat->frames[frame].y = 20 + (y * 15);
|
||||
frame++;
|
||||
|
||||
}
|
||||
}
|
||||
for (int y = 95; y < 185; y += 30) {
|
||||
@@ -76,7 +77,6 @@ Prota::Prota( JD8_Surface gfx ) : Sprite( gfx ) {
|
||||
}
|
||||
|
||||
void Prota::draw() {
|
||||
|
||||
Sprite::draw();
|
||||
|
||||
if (info::num_piramide == 4 && this->o != 4) {
|
||||
@@ -89,7 +89,6 @@ void Prota::draw() {
|
||||
}
|
||||
|
||||
Uint8 Prota::update() {
|
||||
|
||||
Uint8 eixir = 0;
|
||||
|
||||
if (this->o < 4) {
|
||||
@@ -141,10 +140,13 @@ Uint8 Prota::update() {
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 0) {
|
||||
this->cur_frame++;
|
||||
if (this->cur_frame == this->entitat->animacions[this->o].num_frames) {
|
||||
if( this->o == 4 ) { eixir = 1; } else { eixir = 2; }
|
||||
if (this->o == 4) {
|
||||
eixir = 1;
|
||||
} else {
|
||||
eixir = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return eixir;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "game/sprite.hpp"
|
||||
#include "game/info.hpp"
|
||||
#include "game/sprite.hpp"
|
||||
|
||||
class Prota : public Sprite {
|
||||
|
||||
public:
|
||||
|
||||
Prota(JD8_Surface gfx);
|
||||
|
||||
void draw();
|
||||
@@ -16,6 +14,4 @@ public:
|
||||
bool pergami;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
#include "game/sprite.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
Sprite::Sprite(JD8_Surface gfx) {
|
||||
|
||||
this->gfx = gfx;
|
||||
this->entitat = NULL;
|
||||
|
||||
}
|
||||
|
||||
Sprite::~Sprite(void) {
|
||||
|
||||
if (this->entitat != NULL) {
|
||||
|
||||
if (this->entitat->num_frames > 0) free(this->entitat->frames);
|
||||
|
||||
if (this->entitat->num_animacions > 0) {
|
||||
@@ -22,17 +19,8 @@ Sprite::~Sprite(void) {
|
||||
|
||||
free(this->entitat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Sprite::draw() {
|
||||
|
||||
JD8_BlitCK( this->x, this->y, this->gfx, this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].x,
|
||||
this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].y,
|
||||
this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].w,
|
||||
this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].h,
|
||||
255);
|
||||
|
||||
JD8_BlitCK(this->x, this->y, this->gfx, this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].x, this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].y, this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].w, this->entitat->frames[this->entitat->animacions[this->o].frames[this->cur_frame]].h, 255);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ struct Entitat {
|
||||
};
|
||||
|
||||
class Sprite {
|
||||
|
||||
public:
|
||||
|
||||
Sprite(JD8_Surface gfx);
|
||||
~Sprite(void);
|
||||
|
||||
@@ -37,8 +35,6 @@ public:
|
||||
Uint16 o;
|
||||
|
||||
protected:
|
||||
|
||||
JD8_Surface gfx;
|
||||
Uint8 cycles_per_frame;
|
||||
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#include "core/jgame.hpp"
|
||||
#include "core/jdraw8.hpp"
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
|
||||
#include "core/jail_audio.hpp"
|
||||
#include "core/jdraw8.hpp"
|
||||
#include "core/jfile.hpp"
|
||||
#include "core/jgame.hpp"
|
||||
#include "game/defines.hpp"
|
||||
#include "game/info.hpp"
|
||||
#include "game/modulegame.hpp"
|
||||
#include "game/modulesequence.hpp"
|
||||
#include "game/options.hpp"
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char* args[]) {
|
||||
|
||||
srand(unsigned(time(NULL)));
|
||||
|
||||
// Crea la carpeta de configuració i carrega les opcions
|
||||
|
||||
Reference in New Issue
Block a user