commit d3c893d57791e587bccf5ae0fd7c135cc7179beb
parent 49cf79e31f9e6cb38e8bd9866b856f39865e65f8
Author: M. Yamanaka <myamanaka@live.com>
Date: Thu, 21 Jan 2021 18:04:56 -0500
initial skeleton game logic
Diffstat:
A | Makefile | | | 18 | ++++++++++++++++++ |
M | README | | | 1 | + |
A | biblekaruta.c | | | 61 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | biblekaruta.h | | | 62 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
A | crosshair.c | | | 21 | +++++++++++++++++++++ |
A | crosshair.h | | | 33 | +++++++++++++++++++++++++++++++++ |
A | devnotes | | | 5 | +++++ |
A | main.c | | | 27 | +++++++++++++++++++++++++++ |
A | verses.h | | | 123 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
9 files changed, 351 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -0,0 +1,18 @@
+# Bible Karuta Game - Makefile
+# M. Yamanaka
+# email: myamanaka@live.com
+# website: csmyamanaka.com
+# license: MIT (See included "LiCENSE" file for details)
+
+CC=gcc
+LFLG=-lSDL2
+FILES=main.c biblekaruta.c crosshair.c
+OUT=BibleKaruta
+
+all: $(OUT)
+
+$(OUT): $(FILES)
+ $(CC) $^ $(LFLG) -o $@
+
+clean:
+ rm -f $(OUT)
diff --git a/README b/README
@@ -6,6 +6,7 @@ website: csmyamanaka.com
license: MIT (See included "LICENSE" file for details)
NOTE: PROJECT INCOMPLETE! STILL A WORK IN PROGRESS!
+ See "devnotes" for development details
Description:
============
diff --git a/biblekaruta.c b/biblekaruta.c
@@ -0,0 +1,61 @@
+/*
+ Bible Karuta Game - game source file
+ "biblekaruta.c"
+ M. Yamanaka
+ email: myamanaka@live.com
+ website: csmyamanaka.com
+ license: MIT (See included "LICENSE" file for details)
+*/
+
+#include "biblekaruta.h"
+
+int initBibleKG(BibleKG** G){
+ /*
+ Bible Karuta constructor
+ Arguments:
+ G ... reference to a reference to aBible karuta game (not a typo)
+ */
+
+ *G = malloc(sizeof(BibleKG));
+ (*G)->ms = 0;
+ (*G)->ps = 0;
+ (*G)->w = 800;
+ (*G)->h = 600;
+ (*G)->t = "Bible Karuta";
+ (*G)->C.pos[0] = 0;
+ (*G)->C.pos[1] = 0;
+ (*G)->C.gs = 0;
+ (*G)->C.as = 0;
+ (*G)->C.fn = "sprite.png";
+ return 0;
+}
+
+int closeBibleKG(BibleKG* G){
+ /*
+ Bible Karuta destructor
+ Arguments:
+ G ... reference to Bible karuta game
+ */
+ return 0;
+}
+
+int drawBibleKG(BibleKG G){
+ /*
+ Bible Karuta draw function
+ Arguments:
+ G ... Bible Karuta game object
+ */
+ drawCrosshair(G.C);
+ return 0;
+}
+
+int execBibleKG(BibleKG* G){
+ /*
+ The main game loop for Bible Karuta
+ */
+ G->ms = 1;
+ while(G->ms){
+ drawBibleKG(*G);
+ }
+ return 0;
+}
diff --git a/biblekaruta.h b/biblekaruta.h
@@ -0,0 +1,62 @@
+/*
+ Bible Karuta Game - game header file
+ "biblekaruta.h"
+ M. Yamanaka
+ email: myamanaka@live.com
+ website: csmyamanaka.com
+ license: MIT (See included "LICENSE" file for details)
+*/
+
+#pragma once
+
+#include "crosshair.h"
+#include "verses.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <SDL2/SDL.h>
+
+/*
+ Bible Karuta game object struct
+ Serves as a overall manager of the karuta game
+ Member variables in order:
+ ms ... main state: menu, play, view controls, etc
+ ps ... play states: play, pause, disabled
+ w ... game window width
+ h ... game window height
+ t ... game title
+ e ... SDL Event object
+ win ... SDL main game window
+ main ... main SDL drawing surface
+ C ... crosshair object;
+ cards ... cards array
+*/
+typedef struct BibleKG{
+ int ms, ps, w, h;
+ const char* t;
+ SDL_Event e;
+ SDL_Window* win;
+ SDL_Renderer* main;
+ Crosshair C;
+ int cards[500];
+} BibleKG;
+
+/*
+ The "constructor" for the Bible Karuta Game
+*/
+int initBibleKG(BibleKG**);
+
+/*
+ The "destructor" for the Bible Karuta Game
+*/
+int closeBibleKG(BibleKG*);
+
+/*
+ The "draw" function for the Bible Karuta Game
+*/
+int drawBibleKG(BibleKG);
+
+/*
+ Bible Karuta game loop
+*/
+int execBibleKG(BibleKG*);
diff --git a/crosshair.c b/crosshair.c
@@ -0,0 +1,21 @@
+/*
+ Bible Karuta Game - Crosshair source file
+ "crosshair.c"
+ M. Yamanaka
+ email: myamanaka@live.com
+ website: csmyamanaka.com
+ license: MIT (See included "LICENSE" file for details)
+*/
+
+#include "crosshair.h"
+
+int drawCrosshair(const Crosshair C){
+ /*
+ Draw crosshair object
+ Arguments:
+ C ... reference to crosshair object
+ returns an integer indicating the success or nah
+ execution.
+ */
+ return 0;
+}
diff --git a/crosshair.h b/crosshair.h
@@ -0,0 +1,33 @@
+/*
+ Bible Karuta Game - Crosshair header file
+ "crosshair.h"
+ M. Yamanaka
+ email: myamanaka@live.com
+ website: csmyamanaka.com
+ license: MIT (See included "LICENSE" file for details)
+*/
+
+#include <stdlib.h>
+
+/*
+ The crosshair object
+ Member variables in order:
+ pos ... xy-coordinates
+ gs ... overall state of crosshair: disabled, invisible, etc
+ as ... animation state of crosshair i.e. frame in spritesheet
+ fn ... file name of spritesheet file
+*/
+typedef struct Crosshair{ int pos[2], gs, as; const char* fn; } Crosshair;
+
+/*
+ Draw crosshair object
+ The crosshair struct should have all of the necessary information
+ required to draw the object so the crosshair object is the only
+ argument required in this function. Note that the object itself
+ is passed since no changes are made by the draw function.
+ Arguments:
+ Crosshair* ... crosshair object
+ This function returns an integer indicating the successfulnes of its
+ execution.
+*/
+int drawCrosshair(const Crosshair);
diff --git a/devnotes b/devnotes
@@ -0,0 +1,5 @@
+Thurs, 21st of January, 2021
+ - Most of skeleton game logic written
+ - The "initBibleKG" function takes a double pointer at this time
+ not a big fan of this because it looks messy. May change later
+ TODO: implement drawing functions with SDL
diff --git a/main.c b/main.c
@@ -0,0 +1,27 @@
+/*
+ Bible Karuta Game main file
+ "main.c"
+ M. Yamanaka
+ email: myamanaka@live.com
+ website: csmyamanaka.com
+ license: MIT (See included "LICENSE" file for details)
+*/
+
+#include "biblekaruta.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(){
+ printf("game starting ...\n");
+ BibleKG* G = NULL;
+
+ initBibleKG(&G);
+
+ execBibleKG(G);
+
+ printf("closing game ...\n");
+ closeBibleKG(G);
+ printf("game ended ...\n");
+ return 0;
+}
diff --git a/verses.h b/verses.h
@@ -0,0 +1,123 @@
+/*
+ Bible Karuta Game - Bible Verses
+ "verses.h"
+ M. Yamanaka
+ email: myamanaka@live.com
+ website: csmyamanaka.com
+ license: MIT (See included "LICENSE" file for details)
+*/
+
+#pragma once
+
+/*
+ Doulbe bible verses count
+ The reason it's doubled is to account for the fact that
+ each verse is divided into two parts so that the game
+ of karuta can actually be played so in reality, there are
+ 100 verses
+*/
+#define WVC 200
+
+/* array containing bible verses for the game*/
+static const char* verses[WVC] = {
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", "",
+ "", ""
+};