aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/bgFarTree.pngbin38790 -> 0 bytes
-rw-r--r--assets/bgFrontTree.pngbin26111 -> 0 bytes
-rw-r--r--assets/bgMidTree.pngbin28537 -> 0 bytes
-rw-r--r--assets/invUI.pngbin411 -> 0 bytes
-rw-r--r--assets/lightTest/Makefile6
-rw-r--r--assets/lightTest/main.cp0
-rw-r--r--assets/lightTest/main.cpp67
-rw-r--r--assets/player/maybeplayer.png (renamed from assets/maybeplayer.png)bin4146 -> 4146 bytes
-rw-r--r--assets/player/player.png (renamed from assets/player.png)bin543 -> 543 bytes
-rw-r--r--assets/player/player1.png (renamed from assets/player1.png)bin552 -> 552 bytes
-rw-r--r--assets/player/player2.png (renamed from assets/player2.png)bin557 -> 557 bytes
-rw-r--r--assets/player/playerk.png (renamed from assets/playerk.png)bin473 -> 473 bytes
-rw-r--r--assets/player/playerk1.png (renamed from assets/playerk1.png)bin482 -> 482 bytes
-rw-r--r--assets/player/playerk2.png (renamed from assets/playerk2.png)bin478 -> 478 bytes
-rw-r--r--assets/player/playerk3.png (renamed from assets/playerk3.png)bin490 -> 490 bytes
-rw-r--r--assets/player/playerk4.png (renamed from assets/playerk4.png)bin478 -> 478 bytes
-rw-r--r--assets/player/playerk5.png (renamed from assets/playerk5.png)bin472 -> 472 bytes
-rw-r--r--assets/player/playerk6.png (renamed from assets/playerk6.png)bin475 -> 475 bytes
-rw-r--r--assets/player/playerk7.png (renamed from assets/playerk7.png)bin485 -> 485 bytes
-rw-r--r--assets/player/playerk8.png (renamed from assets/playerk8.png)bin489 -> 489 bytes
-rw-r--r--assets/sounds/click.wav (renamed from assets/click.wav)bin17684 -> 17684 bytes
-rw-r--r--assets/style/classic/bg/bg.png (renamed from assets/bg.png)bin1072758 -> 1072758 bytes
-rw-r--r--assets/style/classic/bg/bgFarMountain.png (renamed from assets/bgFarMountain.png)bin20172 -> 20172 bytes
-rw-r--r--assets/style/classic/bg/bgFarTreeTile.png (renamed from assets/bgFarTreeTile.png)bin9433 -> 9433 bytes
-rw-r--r--assets/style/classic/bg/bgFrontTreeTile.png (renamed from assets/bgFrontTreeTile.png)bin27660 -> 27660 bytes
-rw-r--r--assets/style/classic/bg/bgMidTreeTile.png (renamed from assets/bgMidTreeTile.png)bin30605 -> 30605 bytes
-rw-r--r--assets/style/classic/bg/bgfarMountains.png (renamed from assets/bgfarMountains.png)bin30875 -> 30875 bytes
-rw-r--r--assets/style/classic/bg/bgn.png (renamed from assets/bgn.png)bin1438185 -> 1438185 bytes
-rw-r--r--assets/style/classic/bg/dirt.png (renamed from assets/dirt.png)bin228 -> 228 bytes
-rw-r--r--assets/style/classic/bg/forestTileBack.png (renamed from assets/forestTileBack.png)bin9657 -> 9657 bytes
-rw-r--r--assets/style/classic/bg/forestTileFront.png (renamed from assets/forestTileFront.png)bin26722 -> 26722 bytes
-rw-r--r--assets/style/classic/bg/forestTileMid.png (renamed from assets/forestTileMid.png)bin45450 -> 45450 bytes
-rw-r--r--assets/style/classic/bg/grass.png (renamed from assets/grass.png)bin128 -> 128 bytes
-rw-r--r--assets/style/classic/brazzier.png (renamed from assets/brazzier.png)bin282 -> 282 bytes
-rw-r--r--assets/style/classic/fountain1.png (renamed from assets/fountain1.png)bin524 -> 524 bytes
-rw-r--r--assets/style/classic/house1.png (renamed from assets/house1.png)bin749 -> 749 bytes
-rw-r--r--assets/style/classic/house1N.png (renamed from assets/house1N.png)bin1464 -> 1464 bytes
-rw-r--r--assets/style/classic/house2.png (renamed from assets/house2.png)bin747 -> 747 bytes
-rw-r--r--assets/style/classic/lampPost1.png (renamed from assets/lampPost1.png)bin309 -> 309 bytes
-rw-r--r--assets/style/classic/townhall.png (renamed from assets/townhall.png)bin802 -> 802 bytes
-rw-r--r--assets/style/rustic/bg/bg.pngbin0 -> 1072758 bytes
-rw-r--r--assets/style/rustic/bg/bgFarMountain.pngbin0 -> 20172 bytes
-rw-r--r--assets/style/rustic/bg/bgFarTreeTile.pngbin0 -> 9433 bytes
-rw-r--r--assets/style/rustic/bg/bgFrontTreeTile.pngbin0 -> 27660 bytes
-rw-r--r--assets/style/rustic/bg/bgMidTreeTile.pngbin0 -> 30605 bytes
-rw-r--r--assets/style/rustic/bg/bgfarMountains.pngbin0 -> 30875 bytes
-rw-r--r--assets/style/rustic/bg/bgn.pngbin0 -> 1438185 bytes
-rw-r--r--assets/style/rustic/bg/dirt.pngbin0 -> 214 bytes
-rw-r--r--assets/style/rustic/bg/forestTileBack.pngbin0 -> 9657 bytes
-rw-r--r--assets/style/rustic/bg/forestTileFront.pngbin0 -> 26689 bytes
-rw-r--r--assets/style/rustic/bg/forestTileMid.pngbin0 -> 45450 bytes
-rw-r--r--assets/style/rustic/bg/grass.pngbin0 -> 104 bytes
-rw-r--r--assets/style/rustic/fountain1.pngbin0 -> 6972 bytes
-rw-r--r--include/Texture.h2
-rw-r--r--include/common.h3
-rw-r--r--include/entities.h4
-rw-r--r--include/world.h21
-rw-r--r--src/Texture.cpp24
-rw-r--r--src/entities.cpp60
-rw-r--r--src/ui.cpp15
-rw-r--r--src/world.cpp110
-rw-r--r--xml/playerSpawnHill1.xml12
-rw-r--r--xml/playerSpawnHill2.xml7
63 files changed, 162 insertions, 169 deletions
diff --git a/assets/bgFarTree.png b/assets/bgFarTree.png
deleted file mode 100644
index 8b78cae..0000000
--- a/assets/bgFarTree.png
+++ /dev/null
Binary files differ
diff --git a/assets/bgFrontTree.png b/assets/bgFrontTree.png
deleted file mode 100644
index 2cb54ad..0000000
--- a/assets/bgFrontTree.png
+++ /dev/null
Binary files differ
diff --git a/assets/bgMidTree.png b/assets/bgMidTree.png
deleted file mode 100644
index 35f0c14..0000000
--- a/assets/bgMidTree.png
+++ /dev/null
Binary files differ
diff --git a/assets/invUI.png b/assets/invUI.png
deleted file mode 100644
index 8647e38..0000000
--- a/assets/invUI.png
+++ /dev/null
Binary files differ
diff --git a/assets/lightTest/Makefile b/assets/lightTest/Makefile
deleted file mode 100644
index c4d1042..0000000
--- a/assets/lightTest/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-LIBS = -lGL -lGLEW -lSDL2main -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer
-
-FLAGS = -m32 -std=c++11 -Iinclude -Iinclude/freetype2
-
-all:
- @g++ $(FLAGS) -o main main.cpp $(LIBS) \ No newline at end of file
diff --git a/assets/lightTest/main.cp b/assets/lightTest/main.cp
deleted file mode 100644
index e69de29..0000000
--- a/assets/lightTest/main.cp
+++ /dev/null
diff --git a/assets/lightTest/main.cpp b/assets/lightTest/main.cpp
deleted file mode 100644
index 4091389..0000000
--- a/assets/lightTest/main.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <GL/glew.h>
-
-#include <SDL2/SDL.h>
-#include <SDL2/SDL_opengl.h>
-#include <SDL2/SDL_image.h>
-#include <SDL2/SDL_mixer.h>
-#include <iostream>
-
-#define SCREEN_WIDTH 1280
-#define SCREEN_HEIGHT 720
-
-SDL_Window* window;
-SDL_GLContext mainGLContext = NULL;
-
-int main(void){
- if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0){
- std::cout << "SDL was not able to initialize! Error: " << SDL_GetError() << std::endl;
- return -1;
- }
- // Run SDL_Quit when main returns
- atexit(SDL_Quit);
-
- window = SDL_CreateWindow("Ass",
- SDL_WINDOWPOS_UNDEFINED, // Spawn the window at random (undefined) x and y coordinates
- SDL_WINDOWPOS_UNDEFINED, //
- SCREEN_WIDTH,
- SCREEN_HEIGHT,
- SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL
-#ifdef FULLSCREEN
- | SDL_WINDOW_FULLSCREEN
-#endif // FULLSCREEN
- );
-
- if(window==NULL){
- std::cout << "The window failed to generate! SDL_Error: " << SDL_GetError() << std::endl;
- return -1;
- }
-
- if((mainGLContext = SDL_GL_CreateContext(window)) == NULL){
- std::cout << "The OpenGL context failed to initialize! SDL_Error: " << SDL_GetError() << std::endl;
- return -1;
- }
-
-
- GLenum err;
- glewExperimental = GL_TRUE;
- if((err=glewInit()) != GLEW_OK){
- std::cout << "GLEW was not able to initialize! Error: " << glewGetErrorString(err) << std::endl;
- return -1;
- }
-
- SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-
- glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-
- bool gameRunning = true;
- while(gameRunning){
-
- }
- SDL_GL_DeleteContext(mainGLContext);
- SDL_DestroyWindow(window);
- return 0;
-} \ No newline at end of file
diff --git a/assets/maybeplayer.png b/assets/player/maybeplayer.png
index c580ff7..c580ff7 100644
--- a/assets/maybeplayer.png
+++ b/assets/player/maybeplayer.png
Binary files differ
diff --git a/assets/player.png b/assets/player/player.png
index 3977092..3977092 100644
--- a/assets/player.png
+++ b/assets/player/player.png
Binary files differ
diff --git a/assets/player1.png b/assets/player/player1.png
index edf8bf8..edf8bf8 100644
--- a/assets/player1.png
+++ b/assets/player/player1.png
Binary files differ
diff --git a/assets/player2.png b/assets/player/player2.png
index cfd955f..cfd955f 100644
--- a/assets/player2.png
+++ b/assets/player/player2.png
Binary files differ
diff --git a/assets/playerk.png b/assets/player/playerk.png
index 7abf012..7abf012 100644
--- a/assets/playerk.png
+++ b/assets/player/playerk.png
Binary files differ
diff --git a/assets/playerk1.png b/assets/player/playerk1.png
index 1c4fb49..1c4fb49 100644
--- a/assets/playerk1.png
+++ b/assets/player/playerk1.png
Binary files differ
diff --git a/assets/playerk2.png b/assets/player/playerk2.png
index 97f769b..97f769b 100644
--- a/assets/playerk2.png
+++ b/assets/player/playerk2.png
Binary files differ
diff --git a/assets/playerk3.png b/assets/player/playerk3.png
index 19b97c4..19b97c4 100644
--- a/assets/playerk3.png
+++ b/assets/player/playerk3.png
Binary files differ
diff --git a/assets/playerk4.png b/assets/player/playerk4.png
index c32a9b3..c32a9b3 100644
--- a/assets/playerk4.png
+++ b/assets/player/playerk4.png
Binary files differ
diff --git a/assets/playerk5.png b/assets/player/playerk5.png
index fabfa60..fabfa60 100644
--- a/assets/playerk5.png
+++ b/assets/player/playerk5.png
Binary files differ
diff --git a/assets/playerk6.png b/assets/player/playerk6.png
index 269fccb..269fccb 100644
--- a/assets/playerk6.png
+++ b/assets/player/playerk6.png
Binary files differ
diff --git a/assets/playerk7.png b/assets/player/playerk7.png
index aeac120..aeac120 100644
--- a/assets/playerk7.png
+++ b/assets/player/playerk7.png
Binary files differ
diff --git a/assets/playerk8.png b/assets/player/playerk8.png
index ff03a02..ff03a02 100644
--- a/assets/playerk8.png
+++ b/assets/player/playerk8.png
Binary files differ
diff --git a/assets/click.wav b/assets/sounds/click.wav
index 976fb42..976fb42 100644
--- a/assets/click.wav
+++ b/assets/sounds/click.wav
Binary files differ
diff --git a/assets/bg.png b/assets/style/classic/bg/bg.png
index 2dbc3f9..2dbc3f9 100644
--- a/assets/bg.png
+++ b/assets/style/classic/bg/bg.png
Binary files differ
diff --git a/assets/bgFarMountain.png b/assets/style/classic/bg/bgFarMountain.png
index eb703bb..eb703bb 100644
--- a/assets/bgFarMountain.png
+++ b/assets/style/classic/bg/bgFarMountain.png
Binary files differ
diff --git a/assets/bgFarTreeTile.png b/assets/style/classic/bg/bgFarTreeTile.png
index 07546a5..07546a5 100644
--- a/assets/bgFarTreeTile.png
+++ b/assets/style/classic/bg/bgFarTreeTile.png
Binary files differ
diff --git a/assets/bgFrontTreeTile.png b/assets/style/classic/bg/bgFrontTreeTile.png
index 7fc7450..7fc7450 100644
--- a/assets/bgFrontTreeTile.png
+++ b/assets/style/classic/bg/bgFrontTreeTile.png
Binary files differ
diff --git a/assets/bgMidTreeTile.png b/assets/style/classic/bg/bgMidTreeTile.png
index 126723e..126723e 100644
--- a/assets/bgMidTreeTile.png
+++ b/assets/style/classic/bg/bgMidTreeTile.png
Binary files differ
diff --git a/assets/bgfarMountains.png b/assets/style/classic/bg/bgfarMountains.png
index fa6b349..fa6b349 100644
--- a/assets/bgfarMountains.png
+++ b/assets/style/classic/bg/bgfarMountains.png
Binary files differ
diff --git a/assets/bgn.png b/assets/style/classic/bg/bgn.png
index 2aa3995..2aa3995 100644
--- a/assets/bgn.png
+++ b/assets/style/classic/bg/bgn.png
Binary files differ
diff --git a/assets/dirt.png b/assets/style/classic/bg/dirt.png
index 11252ac..11252ac 100644
--- a/assets/dirt.png
+++ b/assets/style/classic/bg/dirt.png
Binary files differ
diff --git a/assets/forestTileBack.png b/assets/style/classic/bg/forestTileBack.png
index 0ea6022..0ea6022 100644
--- a/assets/forestTileBack.png
+++ b/assets/style/classic/bg/forestTileBack.png
Binary files differ
diff --git a/assets/forestTileFront.png b/assets/style/classic/bg/forestTileFront.png
index e54f631..e54f631 100644
--- a/assets/forestTileFront.png
+++ b/assets/style/classic/bg/forestTileFront.png
Binary files differ
diff --git a/assets/forestTileMid.png b/assets/style/classic/bg/forestTileMid.png
index b23afd2..b23afd2 100644
--- a/assets/forestTileMid.png
+++ b/assets/style/classic/bg/forestTileMid.png
Binary files differ
diff --git a/assets/grass.png b/assets/style/classic/bg/grass.png
index e05fb9b..e05fb9b 100644
--- a/assets/grass.png
+++ b/assets/style/classic/bg/grass.png
Binary files differ
diff --git a/assets/brazzier.png b/assets/style/classic/brazzier.png
index e332599..e332599 100644
--- a/assets/brazzier.png
+++ b/assets/style/classic/brazzier.png
Binary files differ
diff --git a/assets/fountain1.png b/assets/style/classic/fountain1.png
index 46f7c44..46f7c44 100644
--- a/assets/fountain1.png
+++ b/assets/style/classic/fountain1.png
Binary files differ
diff --git a/assets/house1.png b/assets/style/classic/house1.png
index ce97a81..ce97a81 100644
--- a/assets/house1.png
+++ b/assets/style/classic/house1.png
Binary files differ
diff --git a/assets/house1N.png b/assets/style/classic/house1N.png
index 0285533..0285533 100644
--- a/assets/house1N.png
+++ b/assets/style/classic/house1N.png
Binary files differ
diff --git a/assets/house2.png b/assets/style/classic/house2.png
index 7404cd9..7404cd9 100644
--- a/assets/house2.png
+++ b/assets/style/classic/house2.png
Binary files differ
diff --git a/assets/lampPost1.png b/assets/style/classic/lampPost1.png
index 24f1807..24f1807 100644
--- a/assets/lampPost1.png
+++ b/assets/style/classic/lampPost1.png
Binary files differ
diff --git a/assets/townhall.png b/assets/style/classic/townhall.png
index 7b510e8..7b510e8 100644
--- a/assets/townhall.png
+++ b/assets/style/classic/townhall.png
Binary files differ
diff --git a/assets/style/rustic/bg/bg.png b/assets/style/rustic/bg/bg.png
new file mode 100644
index 0000000..2dbc3f9
--- /dev/null
+++ b/assets/style/rustic/bg/bg.png
Binary files differ
diff --git a/assets/style/rustic/bg/bgFarMountain.png b/assets/style/rustic/bg/bgFarMountain.png
new file mode 100644
index 0000000..eb703bb
--- /dev/null
+++ b/assets/style/rustic/bg/bgFarMountain.png
Binary files differ
diff --git a/assets/style/rustic/bg/bgFarTreeTile.png b/assets/style/rustic/bg/bgFarTreeTile.png
new file mode 100644
index 0000000..07546a5
--- /dev/null
+++ b/assets/style/rustic/bg/bgFarTreeTile.png
Binary files differ
diff --git a/assets/style/rustic/bg/bgFrontTreeTile.png b/assets/style/rustic/bg/bgFrontTreeTile.png
new file mode 100644
index 0000000..7fc7450
--- /dev/null
+++ b/assets/style/rustic/bg/bgFrontTreeTile.png
Binary files differ
diff --git a/assets/style/rustic/bg/bgMidTreeTile.png b/assets/style/rustic/bg/bgMidTreeTile.png
new file mode 100644
index 0000000..126723e
--- /dev/null
+++ b/assets/style/rustic/bg/bgMidTreeTile.png
Binary files differ
diff --git a/assets/style/rustic/bg/bgfarMountains.png b/assets/style/rustic/bg/bgfarMountains.png
new file mode 100644
index 0000000..fa6b349
--- /dev/null
+++ b/assets/style/rustic/bg/bgfarMountains.png
Binary files differ
diff --git a/assets/style/rustic/bg/bgn.png b/assets/style/rustic/bg/bgn.png
new file mode 100644
index 0000000..2aa3995
--- /dev/null
+++ b/assets/style/rustic/bg/bgn.png
Binary files differ
diff --git a/assets/style/rustic/bg/dirt.png b/assets/style/rustic/bg/dirt.png
new file mode 100644
index 0000000..038aae1
--- /dev/null
+++ b/assets/style/rustic/bg/dirt.png
Binary files differ
diff --git a/assets/style/rustic/bg/forestTileBack.png b/assets/style/rustic/bg/forestTileBack.png
new file mode 100644
index 0000000..0ea6022
--- /dev/null
+++ b/assets/style/rustic/bg/forestTileBack.png
Binary files differ
diff --git a/assets/style/rustic/bg/forestTileFront.png b/assets/style/rustic/bg/forestTileFront.png
new file mode 100644
index 0000000..8e532bb
--- /dev/null
+++ b/assets/style/rustic/bg/forestTileFront.png
Binary files differ
diff --git a/assets/style/rustic/bg/forestTileMid.png b/assets/style/rustic/bg/forestTileMid.png
new file mode 100644
index 0000000..b23afd2
--- /dev/null
+++ b/assets/style/rustic/bg/forestTileMid.png
Binary files differ
diff --git a/assets/style/rustic/bg/grass.png b/assets/style/rustic/bg/grass.png
new file mode 100644
index 0000000..6a35d8e
--- /dev/null
+++ b/assets/style/rustic/bg/grass.png
Binary files differ
diff --git a/assets/style/rustic/fountain1.png b/assets/style/rustic/fountain1.png
new file mode 100644
index 0000000..ff242bf
--- /dev/null
+++ b/assets/style/rustic/fountain1.png
Binary files differ
diff --git a/include/Texture.h b/include/Texture.h
index 50681bf..c6376cb 100644
--- a/include/Texture.h
+++ b/include/Texture.h
@@ -33,6 +33,7 @@ namespace Texture{
void initColorIndex();
vec2 getIndex(Color c);
+ dim2 imageDim(const char *fileName);
}
/**
@@ -71,6 +72,7 @@ public:
*/
Texturec(uint amt,const char **paths);
+ Texturec(std::vector<std::string>vec);
/**
* Frees memory taken by the image array.
diff --git a/include/common.h b/include/common.h
index 0a8ba20..34260c9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -234,6 +234,9 @@ const char *readFile(const char *path);
int strCreateFunc(const char *equ);
+template<typename N, size_t s>
+size_t arrAmt(N (&)[s]){return s;}
+
extern void *NULLPTR;
#endif // COMMON_H
diff --git a/include/entities.h b/include/entities.h
index 9cc1b31..05ae64c 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -26,7 +26,7 @@ enum _TYPE {
enum GENDER{
MALE,
FEMALE,
- NONE
+ TRANSBULLSHIT
};
enum MOB_SUB {
@@ -195,7 +195,9 @@ public:
class Structures : public Entity{
public:
BUILD_SUB bsubtype;
+ World *inWorld;
char *inside;
+ char *textureLoc;
Structures();
~Structures();
diff --git a/include/world.h b/include/world.h
index 47e11f5..43da6fc 100644
--- a/include/world.h
+++ b/include/world.h
@@ -145,7 +145,7 @@ protected:
*/
Texturec *bgTex;
-
+
/**
* Defines the set of background images that should be used for this world.
*/
@@ -163,6 +163,8 @@ protected:
*/
char *bgm;
+ std::vector<std::string>bgFiles;
+ std::vector<std::string>bgFilesIndoors;
public:
@@ -234,7 +236,14 @@ public:
* A vector of all light elements in this world.
*/
- std::vector<Light > light;
+ std::vector<Light > light;
+
+ /**
+ * Vector of all building textures for the current world style
+ */
+
+ std::vector<std::string > sTexLoc;
+
/**
* NULLifies pointers and allocates necessary memory. This should be
@@ -257,7 +266,7 @@ public:
* the structure.
*/
- void addStructure(BUILD_SUB subtype,float x,float y,const char *inside);
+ void addStructure(BUILD_SUB subtype,float x,float y, char* tex, const char *inside);
//void addVillage(int buildingCount, int npcMin, int npcMax,const char *inside);
/**
@@ -343,6 +352,12 @@ public:
*/
void setBGM(const char *path);
+
+ /**
+ * Sets the worlds style folder
+ */
+
+ void setStyle(const char* pre);
/**
* Plays/stops this world's BGM. If `prev` is not NULL, that world's BGM
diff --git a/src/Texture.cpp b/src/Texture.cpp
index e715b1e..1487dcd 100644
--- a/src/Texture.cpp
+++ b/src/Texture.cpp
@@ -4,6 +4,7 @@
struct texture_t {
char *name;
GLuint tex;
+ dim2 dim;
} __attribute__ ((packed));
struct index_t{
@@ -59,17 +60,28 @@ namespace Texture{
GL_UNSIGNED_BYTE,
image->pixels
);
-
- SDL_FreeSurface(image); // Free the surface
LoadedTexture[LoadedTextureCounter] = new struct texture_t; //(struct texture_t *)malloc(sizeof(struct texture_t));
LoadedTexture[LoadedTextureCounter]->name = new char[strlen(fileName)+1]; //(char *)malloc(safe_strlen(fileName));
LoadedTexture[LoadedTextureCounter]->tex = object;
strcpy(LoadedTexture[LoadedTextureCounter]->name,fileName);
+ LoadedTexture[LoadedTextureCounter]->dim.x = image->w;
+ LoadedTexture[LoadedTextureCounter]->dim.y = image->h;
LoadedTextureCounter++;
+ SDL_FreeSurface(image); // Free the surface
+
return object;
}
+
+ dim2 imageDim(const char *fileName){
+ for(unsigned int i=0;i<LoadedTextureCounter;i++){
+ if(!strcmp(LoadedTexture[i]->name,fileName)){
+ return LoadedTexture[i]->dim;
+ }
+ }
+ return {0,0};
+ }
void freeTextures(void){
for(unsigned int i=0;i<LoadedTextureCounter;i++){
@@ -158,6 +170,14 @@ Texturec::Texturec(uint amt, ...){
va_end(fNames);
}
+Texturec::Texturec(std::vector<std::string>v){
+ texState = 0;
+ image = new GLuint[v.size()];
+ for(unsigned int i = 0; i < v.size(); i++){
+ image[i] = Texture::loadTexture(v[i].c_str());
+ }
+}
+
Texturec::Texturec(uint amt,const char **paths){
texState = 0;
image = new GLuint[amt];
diff --git a/src/entities.cpp b/src/entities.cpp
index 5a9c42a..0469ad2 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -12,15 +12,6 @@ extern Player *player;
extern const char *itemName;
-std::string sTexLoc[] = { "assets/townhall.png",
- "assets/house1.png",
- "assets/house2.png",
- "assets/house1.png",
- "assets/house1.png",
- "assets/fountain1.png",
- "assets/lampPost1.png",
- "assets/brazzier.png"};
-
GLuint waterTex;
void initEntity(){
@@ -95,15 +86,15 @@ Player::Player(){ //sets all of the player specific traits on object creation
subtype = 0;
health = maxHealth = 100;
speed = 1;
- tex = new Texturec(9, "assets/playerk.png",
- "assets/playerk1.png",
- "assets/playerk2.png",
- "assets/playerk3.png",
- "assets/playerk4.png",
- "assets/playerk5.png",
- "assets/playerk6.png",
- "assets/playerk7.png",
- "assets/playerk8.png");
+ tex = new Texturec(9, "assets/player/playerk.png",
+ "assets/player/playerk1.png",
+ "assets/player/playerk2.png",
+ "assets/player/playerk3.png",
+ "assets/player/playerk4.png",
+ "assets/player/playerk5.png",
+ "assets/player/playerk6.png",
+ "assets/player/playerk7.png",
+ "assets/player/playerk8.png");
inv = new Inventory(PLAYER_INV_SIZE);
}
Player::~Player(){
@@ -126,7 +117,7 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
tex = new Texturec(1,"assets/NPC.png");
inv = new Inventory(NPC_INV_SIZE);
- randDialog = 6;//rand() % 12 - 1;
+ randDialog = rand() % 12 - 1;
dialogIndex = 0;
}
NPC::~NPC(){
@@ -462,6 +453,7 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){
alive = true;
bsubtype = sub;
+ dim2 dim;
/*
* tempN is the amount of entities that will be spawned in the village. Currently the village
@@ -470,33 +462,11 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){
//unsigned int tempN = (getRand() % 5 + 2);
switch(sub){
- case TOWN_HALL:
- tex = new Texturec(1, sTexLoc[sub].c_str());
- width = 50 * HLINE;
- height = 40 * HLINE;
-
- break;
- case HOUSE:
- tex = new Texturec(1, sTexLoc[sub].c_str());
- width = 50 * HLINE;
- height = 40 * HLINE;
- break;
- case FOUNTAIN:
- tex = new Texturec(1, sTexLoc[sub].c_str());
- width = 50 * HLINE;
- height = 40 * HLINE;
- break;
- case LAMP_POST:
- tex = new Texturec(1, sTexLoc[sub].c_str());
- width = 10 * HLINE;
- height = 40 * HLINE;
- break;
- case FIRE_PIT:
- tex = new Texturec(1, sTexLoc[sub].c_str());
- width = 12 * HLINE;
- height = 12 * HLINE;
- break;
default:
+ tex = new Texturec(1, textureLoc ? textureLoc : inWorld->sTexLoc[sub].c_str());
+ dim = Texture::imageDim(textureLoc ? textureLoc : inWorld->sTexLoc[sub].c_str());
+ width = dim.x;
+ height = dim.y;
break;
}
return 0;
diff --git a/src/ui.cpp b/src/ui.cpp
index 56a88a3..ead4932 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -146,10 +146,10 @@ namespace ui {
#ifdef DEBUG
DEBUG_printf("Initialized FreeType2.\n",NULL);
#endif // DEBUG
- dialogClick = Mix_LoadWAV("assets/click.wav");
+ dialogClick = Mix_LoadWAV("assets/sounds/click.wav");
battleStart = Mix_LoadWAV("assets/sounds/frig.wav");
sanic = Mix_LoadWAV("assets/sounds/sanic.wav");
- Mix_Volume(1,50);
+ //Mix_Volume(1,50);
}
void destroyFonts(void){
@@ -258,9 +258,11 @@ namespace ui {
* Draws a character at the specified coordinates, aborting if the character is unknown.
*/
- vec2 putChar(float x,float y,char c){
+ vec2 putChar(float xx,float yy,char c){
vec2 c1,c2;
-
+
+ int x = xx, y = yy;
+
/*
* Get the width and height of the rendered character.
*/
@@ -725,8 +727,7 @@ namespace ui {
*/
void drawMenu(Menu *menu){
-
- setFontSize(20);
+ setFontSize(18);
SDL_Event e;
mouse.x=premouse.x+offset.x-(SCREEN_WIDTH/2);
@@ -1229,7 +1230,7 @@ DONE:
//currentWorld->addVillage(player->loc.x, player->loc.y, 5, 10, 100, NULL);
break;
case SDLK_b:
- currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, NULL);
+ currentWorld->addStructure(FIRE_PIT, player->loc.x, player->loc.y, NULL, NULL);
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
break;
case SDLK_F12:
diff --git a/src/world.cpp b/src/world.cpp
index 6118851..2012d32 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -17,23 +17,49 @@ bool worldInside = false; // True if player is inside a structure
WEATHER weather = SUNNY;
-const char *bgPaths[2][7]={
- {"assets/bg.png", // Daytime background
- "assets/bgn.png", // Nighttime background
- "assets/bgFarMountain.png", // Furthest layer
- "assets/forestTileBack.png", // Closer layer
- "assets/forestTileMid.png", // Near layer
- "assets/forestTileFront.png", // Closest layer
- "assets/dirt.png"}, // Dirt
- {"assets/bgWoodTile.png",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL}
+// const char *bgPaths[2][7]={
+// {"assets/bg.png", // Daytime background
+// "assets/bgn.png", // Nighttime background
+// "assets/bgFarMountain.png", // Furthest layer
+// "assets/forestTileBack.png", // Closer layer
+// "assets/forestTileMid.png", // Near layer
+// "assets/forestTileFront.png", // Closest layer
+// "assets/dirt.png"}, // Dirt
+// {"assets/bgWoodTile.png",
+// NULL,
+// NULL,
+// NULL,
+// NULL,
+// NULL}
+// };
+
+const std::string bgPaths[2][8]={
+ {"bg.png", // Daytime background
+ "bgn.png", // Nighttime background
+ "bgFarMountain.png", // Furthest layer
+ "forestTileBack.png", // Closer layer
+ "forestTileMid.png", // Near layer
+ "forestTileFront.png", // Closest layer
+ "dirt.png", // Dirt
+ "grass.png"}, // Grass
+ {"bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png",
+ "bgWoodTile.png"}
};
-Texturec *grassT;
+const std::string buildPaths[] = { "townhall.png",
+ "house1.png",
+ "house2.png",
+ "house1.png",
+ "house1.png",
+ "fountain1.png",
+ "lampPost1.png",
+ "brazzier.png"};
const float bgDraw[3][3]={
{100,240,.6 },
@@ -56,14 +82,34 @@ void World::setBackground(WORLD_BG_TYPE bgt){
bgType = bgt;
switch(bgt){
case BG_FOREST:
- bgTex = new Texturec(7,bgPaths[0]);
+ bgTex = new Texturec(bgFiles);
break;
case BG_WOODHOUSE:
- bgTex = new Texturec(1,bgPaths[1]);
+ bgTex = new Texturec(bgFilesIndoors);
break;
}
}
+void World::setStyle(const char* pre){
+ std::string prefix = pre ? pre : "assets/style/classic/";
+ for(uint i = 0; i < arrAmt(buildPaths);i++){
+ sTexLoc.push_back(prefix);
+ sTexLoc.back() += buildPaths[i];
+ std::cout << sTexLoc.back() << std::endl;
+ }
+ prefix += "bg/";
+ for(uint i = 0; i < arrAmt(bgPaths[0]);i++){
+ bgFiles.push_back(prefix);
+ bgFiles.back() += bgPaths[0][i];
+ std::cout << bgFiles.back() << std::endl;
+ }
+ for(uint i = 0; i < arrAmt(bgPaths[1]);i++){
+ bgFilesIndoors.push_back(prefix);
+ bgFilesIndoors.back() += bgPaths[1][i];
+ std::cout << bgFilesIndoors.back() << std::endl;
+ }
+}
+
World::World(void){
bgm = NULL;
@@ -78,7 +124,6 @@ World::World(void){
star = new vec2[100];
memset(star,0,100 * sizeof(vec2));
- grassT = new Texturec(1,"assets/grass.png");
}
void World::deleteEntities(void){
@@ -595,10 +640,10 @@ void World::draw(Player *p){
hey=true;
glColor4ub(0,0,0,255);
}else safeSetColorA(150+shade*2,150+shade*2,150+shade*2,255);
- glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT);
- glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT);
+ glTexCoord2i(0,0); glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT);
+ glTexCoord2i(1,0); glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT);
glTexCoord2i(1,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE+HLINE,0);
- glTexCoord2i(0,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE ,0);
+ glTexCoord2i(0,(int)(cline[i].y/64)+cline[i].color);glVertex2i(cx_start+i*HLINE ,0);
cline[i].y-=(yoff-DRAW_Y_OFFSET); // Restore the line's y value
if(hey){
hey=false;
@@ -616,7 +661,7 @@ void World::draw(Player *p){
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
- grassT->bind(0);
+ bgTex->bindNext();
glUseProgram(shaderProgram);
glUniform1i(glGetUniformLocation(shaderProgram, "sampler"), 0);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
@@ -948,10 +993,12 @@ void World::detect(Player *p){
goto LOOOOP;
}*/
}
-void World::addStructure(BUILD_SUB sub, float x,float y,const char *inside){
+void World::addStructure(BUILD_SUB sub, float x,float y, char *tex, const char *inside){
build.push_back(new Structures());
+ build.back()->inWorld = this;
+ build.back()->textureLoc = tex;
build.back()->spawn(sub,x,y);
-
+
if(inside)
strcpy((build.back()->inside = new char[1 + strlen(inside)]),inside);
else
@@ -1071,8 +1118,7 @@ char *World::setToRight(const char *file){
World *World::goWorldLeft(Player *p){
World *tmp;
-
- if(toLeft && p->loc.x < x_start + HLINE * 15){
+ if(toLeft && p->loc.x < x_start + (int)HLINE * 15){
tmp = loadWorldFromXML(toLeft);
p->loc.x = -tmp->x_start - HLINE * 10;
@@ -1474,6 +1520,7 @@ World *loadWorldFromXML(const char *path){
tmp->setToRight(ptr);
else abort();
}else if(!strcmp(name,"style")){
+ tmp->setStyle(wxml->Attribute("folder"));
tmp->setBackground((WORLD_BG_TYPE)wxml->UnsignedAttribute("background"));
tmp->setBGM(wxml->Attribute("bgm"));
}else if(!strcmp(name,"generation")){
@@ -1519,10 +1566,13 @@ World *loadWorldFromXML(const char *path){
}else if(!strcmp(name,"structure")){
ptr = wxml->Attribute("inside");
- if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR)
- tmp->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"),getRand() % tmp->getTheWidth() / 2.0f,100,ptr);
- else
- tmp->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"),spawnx,wxml->FloatAttribute("y"),ptr);
+ tmp->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"),
+ wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR ?
+ getRand() % tmp->getTheWidth() / 2.0f :
+ spawnx,
+ 100,
+ (char*)wxml->Attribute("texture"),
+ ptr);
}else if(!strcmp(name,"trigger")){
tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc);
tmp->mob.back()->heyid = wxml->Attribute("id");
diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml
index 55612d3..a99b274 100644
--- a/xml/playerSpawnHill1.xml
+++ b/xml/playerSpawnHill1.xml
@@ -1,9 +1,8 @@
<?xml version="1.0"?>
<World>
- <style background="0" bgm="assets/music/embark.wav" />
+ <style background="0" bgm="assets/music/embark.wav" folder="assets/style/classic/" />
<generation type="Random" width="1600" />
-
- <link right="playerSpawnHill2.xml" />
+ <link left="playerSpawnHill2.xml" />
<mob type="1" aggressive="false" />
@@ -11,7 +10,10 @@
<npc name="Ralph" hasDialog="true" />
<npc name="Johnny" hasDialog="true" />
- <structure type="5" inside="playerSpawnHill1_Building1.xml" />
+ <structure type="5" inside="playerSpawnHill1_Building1.xml"/>
+ <village>
+
+ </village>
</World>
@@ -33,7 +35,7 @@ And it wasn't stormy.
</text>
<text id="2" call="Johnny" callid="1">
- what you have done it to trick Microsoft
+ what you have done it to trick Microsoft?
</text>
</Dialog>
diff --git a/xml/playerSpawnHill2.xml b/xml/playerSpawnHill2.xml
index 2da7bd3..c46dad3 100644
--- a/xml/playerSpawnHill2.xml
+++ b/xml/playerSpawnHill2.xml
@@ -1,8 +1,9 @@
<?xml version="1.0"?>
<World>
- <style background="0" bgm="assets/music/embark.wav" />
- <generation type="Random" width="500" />
+ <style background="0" bgm="assets/music/embark.wav" folder="assets/style/rustic/"/>
+ <generation type="Random" width="1000" />
+ <structure type="5" inside="playerSpawnHill1_Building1.xml"/>
- <link left="playerSpawnHill1.xml" />
+ <link right="playerSpawnHill1.xml" />
</World>