Skip to content

Commit

Permalink
Made some changes
Browse files Browse the repository at this point in the history
Took out 3D effect and sound from the box. Should not be freezing
anymore.
  • Loading branch information
Manurocker95 committed Apr 17, 2017
1 parent 7b50bf7 commit c6c8857
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 38 deletions.
Binary file modified .vs/WITB_3D/v14/.suo
Binary file not shown.
Binary file modified WITB_3D.VC.db
Binary file not shown.
Binary file modified WITB_3D/WITB_3D-strip.elf
Binary file not shown.
Binary file modified WITB_3D/WITB_3D.3dsx
Binary file not shown.
Binary file modified WITB_3D/WITB_3D.cia
Binary file not shown.
Binary file modified WITB_3D/WITB_3D.elf
Binary file not shown.
4 changes: 2 additions & 2 deletions WITB_3D/source/Filepaths.h
Expand Up @@ -20,8 +20,8 @@ Copyright (C) 2017 Manuel Rodríguez Matesanz
*/

//Documento de Maxima puntuacion
#define DATA_FILE "romfs:/resources/Files/data.txt"
#define DATA2_FILE "sdmc:/witbdata.txt"
#define DATA_FILE "sdmc:/3ds/data/WITB/witbdata.sav"
#define DATA_FILE2 "sdmc:/witbdata.txt"

/* Sonido */
// Música de fondo
Expand Down
25 changes: 13 additions & 12 deletions WITB_3D/source/Game.cpp
Expand Up @@ -61,7 +61,8 @@ void GameScreen::Start()
void GameScreen::Draw()
{

offset = CONFIG_3D_SLIDERSTATE * 20;
// 3D effect
//offset = CONFIG_3D_SLIDERSTATE * 20;

if (!m_ended)
{
Expand Down Expand Up @@ -134,21 +135,20 @@ void GameScreen::CheckInputs()
SceneManager::instance()->SaveTapsAndExit(m_taps);
}

if (hidKeysDown() & KEY_START)
{
std::ofstream outfile(DATA_FILE);
outfile << m_taps;
outfile.close();
}

if (DEBUGMODE)
{
if (hidKeysDown() & KEY_R)
{
ResetBG();
}

if (hidKeysDown() & KEY_B)
{
std::ofstream ofs;
ofs.open(DATA2_FILE + '\n');
ofs << m_taps;
ofs.close();
}

if (hidKeysDown() & KEY_L)
{
if (!m_ended)
Expand Down Expand Up @@ -178,12 +178,10 @@ void GameScreen::CheckInputs()
}
else
{
m_taps = 0;
m_player->setYOffset(0);
ResetBG();
}

m_sfxTap->play();
//m_sfxTap->play();
}
}

Expand Down Expand Up @@ -227,6 +225,9 @@ void GameScreen::NewColorBG()

void GameScreen::ResetBG()
{
m_taps = 0;
m_player->setYOffset(0);

sf2d_free_texture(m_bgTop);
sf2d_free_texture(m_bgBot);

Expand Down
2 changes: 2 additions & 0 deletions WITB_3D/source/Game.h
Expand Up @@ -35,6 +35,7 @@
#include <stdio.h>

#define MAXTAPS 1000000
#define TIMER 5

class GameScreen : public Scene
{
Expand All @@ -53,6 +54,7 @@ class GameScreen : public Scene

int m_taps; // Número de Taps
int m_currentBG;
int m_counter;
bool m_ended; // Si hemos acabado
float offset = 0;
touchPosition touch;
Expand Down
49 changes: 34 additions & 15 deletions WITB_3D/source/SceneManager.cpp
Expand Up @@ -30,24 +30,45 @@ SceneManager* SceneManager::instance()

void SceneManager::Start()
{
//MAX SCORE DATA
ifstream myReadFile(DATA2_FILE);
// We read data in 3ds/data/WITB/witb.sav
m_out = false;
ReadData();
}

void SceneManager::ReadData()
{
m_taps = 0;

std::ifstream myReadFile(DATA_FILE);

if (myReadFile.good())
if (myReadFile)
{
myReadFile >> m_taps;
m_actualScene = new SplashScreen();
}
else
{
std::ofstream ofs;
ofs.open(DATA2_FILE + '\n');
ofs << m_taps;
ofs.close();
}
std::ifstream myReadFile2(DATA_FILE2);

m_out = false;
m_actualScene = new SplashScreen();
if (myReadFile2)
{
myReadFile2 >> m_taps;
}
else
{
std::ofstream outfile(DATA_FILE);
outfile << m_taps;
outfile.close();

std::ofstream outfile2(DATA_FILE2);
outfile2 << m_taps;
outfile2.close();


}

m_actualScene = new GameScreen(m_taps);
}
}

void SceneManager::setActualScene(SCENES _scene)
Expand All @@ -63,7 +84,6 @@ void SceneManager::setActualScene(SCENES _scene)
m_actualScene = new GameScreen(m_taps);
break;
}

}

void SceneManager::Update()
Expand Down Expand Up @@ -92,10 +112,9 @@ void SceneManager::SaveTapsAndExit(int _taps)
{
if (_taps >= 0)
{
std::ofstream ofs;
ofs.open(DATA2_FILE);
ofs << _taps;
ofs.close();
std::ofstream outfile(DATA_FILE);
outfile << _taps;
outfile.close();
}

exitGame();
Expand Down
2 changes: 2 additions & 0 deletions WITB_3D/source/SceneManager.h
Expand Up @@ -22,6 +22,7 @@

#include <fstream>
#include <sstream>
#include <sys/unistd.h>
#include "SplashScreen.h"
#include "Game.h"

Expand All @@ -38,6 +39,7 @@ class SceneManager
void Update();
bool isOut();
void exitGame();
void ReadData();
void SaveTapsAndExit(int _taps);

private:
Expand Down
1 change: 1 addition & 0 deletions WITB_3D/source/SplashScreen.cpp
Expand Up @@ -147,6 +147,7 @@ void SplashScreen::Update()

void SplashScreen::GoToGame()
{
delete (m_SFX);
sf2d_free_texture(m_bgTop);
sf2d_free_texture(m_bgBot);
SceneManager::instance()->setActualScene(SceneManager::GAME);
Expand Down
16 changes: 7 additions & 9 deletions WITB_3D/source/main.cpp
Expand Up @@ -37,28 +37,22 @@ typedef SSIZE_T ssize_t;
#include <3ds.h>
#include <sf2d.h>
#include <sftd.h>
#include <random>
#include <time.h>
#include <sys/stat.h>

#include "SceneManager.h"

ndspWaveBuf waveBuf;

int main()
{

// Set the random seed based on the time
srand(time(NULL));

// Inicializamos los servicios
// Srv
srvInit();

// SF2D + SFIL (Imágenes + gpu)
sf2d_init();
sf2d_set_clear_color(RGBA8(0, 0, 0, 255));
//sf2d_set_clear_color(RGBA8(255, 255, 255, 255));
sf2d_set_3D(true);
//sf2d_set_vblank_wait(0);
sf2d_set_3D(false);

//Sftd (Textos)
sftd_init();
Expand All @@ -69,6 +63,10 @@ int main()
// Sound - Necesita dumpear dsp de la consola
ndspInit();

//Creating Data
mkdir("/3ds", 0777);
mkdir("/3ds/data", 0777);
mkdir("/3ds/data/WITB", 0777);

SceneManager::instance()->Start();

Expand Down

0 comments on commit c6c8857

Please sign in to comment.