-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed '#pragma once' as it is not standard, fixed sprite rotation, adde3d
- Loading branch information
1 parent
6a11c3d
commit 6db44ef
Showing
9 changed files
with
425 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "engine.h" | ||
#include "img.h" | ||
#include "fileNames.h" | ||
#include <tinyfiledialogs\tinyfiledialogs.h> | ||
|
||
void Engine::startGame() { | ||
//init window stuff | ||
Engine::startGraphics("OpenNitemare3D", 640, 640); | ||
bool quit = false; | ||
|
||
|
||
|
||
} | ||
|
||
void Engine::startGraphics(const char* Name, int displayWidth, int displayHeight) { | ||
IMG img; | ||
size_t numImages; | ||
FileNames fileIndex; | ||
img.Init("GAME.PAL", "IMG.1"); | ||
numImages = img.GetNumImages(); | ||
SDL_Init(SDL_INIT_VIDEO); | ||
window = SDL_CreateWindow(Name, | ||
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, displayWidth, displayHeight, 0); | ||
renderer = SDL_CreateRenderer(window, -1, 0); | ||
texture = SDL_CreateTextureFromSurface(renderer, img[fileIndex.getSprite("RED_WALL_SINGLE_PAINTING")]); | ||
while (true) | ||
{ | ||
SDL_WaitEvent(&event); | ||
switch (event.type) | ||
{ | ||
case SDL_QUIT: | ||
SDL_DestroyTexture(texture); | ||
//SDL_FreeSurface(image); | ||
SDL_DestroyRenderer(renderer); | ||
SDL_DestroyWindow(window); | ||
|
||
SDL_Quit(); | ||
return; | ||
break; | ||
} | ||
|
||
SDL_Rect dstrect; | ||
dstrect.x = (displayWidth - displayHeight) / 2 - 1; | ||
dstrect.y = (displayHeight - displayWidth) / 2; | ||
dstrect.w = displayHeight; | ||
dstrect.h = displayWidth; //; // SDL_RenderCopyEx(renderer, texture, nullptr, &dstrect, 90, nullptr, SDL_FLIP_NONE); | ||
|
||
|
||
SDL_RenderCopyEx(renderer, texture, nullptr, &dstrect, 90, nullptr, SDL_FLIP_NONE); | ||
SDL_RenderPresent(renderer); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef __ENGINE_H__ | ||
#define __ENGINE_H__ | ||
#include <string> | ||
#include <SDL2/SDL.h> | ||
class Engine | ||
{ | ||
public: | ||
std::string title; | ||
std::string getTitle(); | ||
float version; | ||
float getVersion(); | ||
|
||
int width; | ||
int height; | ||
|
||
void startGame(); | ||
void startGraphics(const char* Name, int displayWidth, int displayHeight); | ||
|
||
|
||
//SDL2 stuff | ||
SDL_Event event; | ||
SDL_Window* window; | ||
SDL_Renderer* renderer; | ||
SDL_Texture* texture; | ||
|
||
|
||
|
||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "fileNames.h" | ||
|
||
#include <string> | ||
|
||
/*this function makes it so you don't have to remember sprite indexes. | ||
Note: not yet complete, incorrectly labled | ||
I unfortunatly have to go through each sprite and label it | ||
*/ | ||
int FileNames::getSprite(std::string index) { | ||
if (index == "RED_WALL_DOUBLE_PLAIN") { | ||
return 0; | ||
} | ||
else if (index == "RED_WALL_SINGLE_PAINTING") { | ||
return 1; | ||
|
||
} | ||
else if (index == "RED_WALL_DOUBLE_CANDLE_FR1") { | ||
return 2; | ||
} | ||
else if (index == "RED_WALL_DOUBLE_CANDLE_FR2") { | ||
return 3; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef __FILENAMES_H__ | ||
#define __FILENAMES_H__ | ||
#include <string> | ||
class FileNames | ||
{ | ||
public: | ||
int getSprite(std::string index); | ||
}; | ||
|
||
#endif | ||
|
Oops, something went wrong.