Compare commits
3 Commits
edfe78f3b7
...
f56837fc6c
| Author | SHA1 | Date | |
|---|---|---|---|
| f56837fc6c | |||
| aeb508f936 | |||
| ca9d789cbd |
BIN
data/z80.png
Normal file
BIN
data/z80.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 413 B |
45
main.cpp
45
main.cpp
@@ -11,6 +11,8 @@ Código fuente creado por JailDesigner
|
|||||||
#include "units/text.h"
|
#include "units/text.h"
|
||||||
#include "units/utils.h"
|
#include "units/utils.h"
|
||||||
#include "units/asset.h"
|
#include "units/asset.h"
|
||||||
|
#include "units/movingsprite.h"
|
||||||
|
#include "units/texture.h"
|
||||||
|
|
||||||
SDL_Event *event;
|
SDL_Event *event;
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
@@ -34,6 +36,7 @@ int main(int argc, char *argv[])
|
|||||||
asset->add("/data/sound.wav", t_sound);
|
asset->add("/data/sound.wav", t_sound);
|
||||||
asset->add("/data/smb2.txt", t_font);
|
asset->add("/data/smb2.txt", t_font);
|
||||||
asset->add("/data/smb2.png", t_bitmap);
|
asset->add("/data/smb2.png", t_bitmap);
|
||||||
|
asset->add("/data/z80.png", t_bitmap);
|
||||||
asset->setVerbose(options->console);
|
asset->setVerbose(options->console);
|
||||||
if (!asset->check())
|
if (!asset->check())
|
||||||
{
|
{
|
||||||
@@ -61,15 +64,28 @@ int main(int argc, char *argv[])
|
|||||||
JA_Init(48000, AUDIO_S16, 2);
|
JA_Init(48000, AUDIO_S16, 2);
|
||||||
|
|
||||||
JA_Music_t *music;
|
JA_Music_t *music;
|
||||||
JA_Sound_t *peiv;
|
JA_Sound_t *sound;
|
||||||
|
|
||||||
music = JA_LoadMusic(asset->get("music.ogg").c_str());
|
music = JA_LoadMusic(asset->get("music.ogg").c_str());
|
||||||
peiv = JA_LoadSound(asset->get("sound.wav").c_str());
|
sound = JA_LoadSound(asset->get("sound.wav").c_str());
|
||||||
int volume = 128;
|
int volume = 128;
|
||||||
|
|
||||||
// Inicializa el texto
|
// Inicializa el texto
|
||||||
Text *text = new Text(asset->get("smb2.txt"), asset->get("smb2.png"), renderer);
|
Text *text = new Text(asset->get("smb2.txt"), asset->get("smb2.png"), renderer);
|
||||||
|
|
||||||
|
// Inicializa el sprite
|
||||||
|
Texture *texture = new Texture(renderer, asset->get("z80.png"));
|
||||||
|
MovingSprite *sprite = new MovingSprite();
|
||||||
|
sprite->setRenderer(renderer);
|
||||||
|
sprite->setTexture(texture);
|
||||||
|
sprite->setPosX(0);
|
||||||
|
sprite->setPosY(0);
|
||||||
|
sprite->setWidth(16);
|
||||||
|
sprite->setHeight(32);
|
||||||
|
sprite->setSpriteClip({0, 0, 16, 32});
|
||||||
|
sprite->setVelX(1);
|
||||||
|
sprite->setVelY(2);
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
// JA_PlayMusic(music, true);
|
// JA_PlayMusic(music, true);
|
||||||
bool should_exit = false;
|
bool should_exit = false;
|
||||||
@@ -103,6 +119,19 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Incrementa el contador
|
// Incrementa el contador
|
||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
|
// Actualiza el sprite
|
||||||
|
if (sprite->getPosX() + sprite->getWidth() > options->gameWidth or sprite->getPosX() < 0)
|
||||||
|
{
|
||||||
|
sprite->setVelX(sprite->getVelX() * -1);
|
||||||
|
JA_PlaySound(sound);
|
||||||
|
}
|
||||||
|
if (sprite->getPosY() + sprite->getHeight() > options->gameHeight or sprite->getPosY() < 0)
|
||||||
|
{
|
||||||
|
sprite->setVelY(sprite->getVelY() * -1);
|
||||||
|
JA_PlaySound(sound);
|
||||||
|
}
|
||||||
|
sprite->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja en pantalla
|
// Dibuja en pantalla
|
||||||
@@ -124,20 +153,26 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
// Escribe el texto
|
// Escribe el texto
|
||||||
text->writeCentered(options->gameWidth / 2, text->getCharacterSize(), "Jail Engine DEMO");
|
text->writeCentered(options->gameWidth / 2, text->getCharacterSize(), "Jail Engine DEMO");
|
||||||
|
// Dibuja el sprite
|
||||||
|
sprite->render();
|
||||||
// Vuelca el buffer en pantalla
|
// Vuelca el buffer en pantalla
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finaliza el objeto con la lista de recuros
|
// Finaliza el sprite
|
||||||
delete asset;
|
delete sprite;
|
||||||
|
delete texture;
|
||||||
|
|
||||||
// Finaliza el texto
|
// Finaliza el texto
|
||||||
delete text;
|
delete text;
|
||||||
|
|
||||||
// Finaliza jail_audio
|
// Finaliza jail_audio
|
||||||
JA_DeleteSound(peiv);
|
JA_DeleteSound(sound);
|
||||||
JA_DeleteMusic(music);
|
JA_DeleteMusic(music);
|
||||||
|
|
||||||
|
// Finaliza el objeto con la lista de recuros
|
||||||
|
delete asset;
|
||||||
|
|
||||||
// Finaliza SDL y la ventana
|
// Finaliza SDL y la ventana
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
|
|||||||
Reference in New Issue
Block a user