summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
Diffstat (limited to 'frontends')
-rw-r--r--frontends/curses/curses_ui.c16
-rw-r--r--frontends/curses/meson.build1
-rw-r--r--frontends/gl/main.c29
-rw-r--r--frontends/gl/res/play_field.pngbin0 -> 814 bytes
-rw-r--r--frontends/gl/res/play_field_shake_1.pngbin0 -> 9007 bytes
-rw-r--r--frontends/gl/res/play_field_shake_2.pngbin0 -> 10769 bytes
-rw-r--r--frontends/gl/res/play_field_shake_3.pngbin0 -> 9551 bytes
-rw-r--r--frontends/gl/res/play_field_shake_4.pngbin0 -> 9954 bytes
8 files changed, 31 insertions, 15 deletions
diff --git a/frontends/curses/curses_ui.c b/frontends/curses/curses_ui.c
index fb58e4d..8456438 100644
--- a/frontends/curses/curses_ui.c
+++ b/frontends/curses/curses_ui.c
@@ -47,12 +47,12 @@
" \\--------------------/"
#else
#define BLOCK "[]"
-#define PLAY_FIELD_STR " ┏━━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━┓ \n"\
+#define PLAY_FIELD_STR " ┏━━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━score━━━━━┓ \n"\
" ┃ ┃ ┃ ┃ \n"\
" ┃ ┃ ┗━━━━━━━━━━━━━━━┛ \n"\
" ┃ ┃ \n"\
" ┃ ┃ \n"\
- " ┃ ┃ ┏━━━━━━━━━━━┓ \n"\
+ " ┃ ┃ ┏━━━queue━━━┓ \n"\
" ┃ ┃ ┃ ┃ \n"\
" ┃ ┃ ┃ ┃ \n"\
" ┃ ┃ ┃ ┃ \n"\
@@ -212,19 +212,19 @@ int main(void) {
if (is_paused) continue; // dont allow input if paused
switch (keys[i]) {
case KEY_LEFT:
- move_piece(&game, LEFT, false); break;
+ move_piece(&game, LEFT); break;
case KEY_RIGHT:
- move_piece(&game, RIGHT, false); break;
+ move_piece(&game, RIGHT); break;
case KEY_DOWN:
- move_piece(&game, DOWN, false); break;
+ move_piece(&game, USER_DOWN); break;
case KEY_UP:
case 'x':
- move_piece(&game, ROTATE_CW, false); break;
+ move_piece(&game, ROTATE_CW); break;
case '^':
case 'z':
- move_piece(&game, ROTATE_CCW, false); break;
+ move_piece(&game, ROTATE_CCW); break;
case ' ':
- move_piece(&game, HARD_DROP, false); break;
+ move_piece(&game, HARD_DROP); break;
case KEY_SLEFT:
case 'c':
hold_piece(&game); break;
diff --git a/frontends/curses/meson.build b/frontends/curses/meson.build
index 8dd1d00..b254239 100644
--- a/frontends/curses/meson.build
+++ b/frontends/curses/meson.build
@@ -8,6 +8,7 @@ if host_machine.system() == 'windows'
deps += compiler.find_library('pdcurses', dirs: meson.current_source_dir() + '/win')
else
deps += dependency('ncursesw')
+ deps += dependency('tinfow')
deps += dependency('threads')
endif
diff --git a/frontends/gl/main.c b/frontends/gl/main.c
index 01da0c9..87cbd19 100644
--- a/frontends/gl/main.c
+++ b/frontends/gl/main.c
@@ -64,12 +64,12 @@ rbg_color colors[8] = {
{0.255f,0.220f,0.0f} // Yellow
};
-struct block_drawable {
+typedef struct {
GLuint vao;
GLuint vbo;
GLuint ebo;
GLuint texture;
-};
+} drawable;
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
@@ -113,7 +113,7 @@ void load_fragment_shader(GLuint program) {
glDeleteShader(fragment_shader);
}
-void create_block(struct block_drawable *b) {
+void create_static_2d(drawable *b, int w, int h, char* texture_file) {
glGenVertexArrays(1, &b->vao);
glGenBuffers(1, &b->vbo);
glGenBuffers(1, &b->ebo);
@@ -124,6 +124,9 @@ void create_block(struct block_drawable *b) {
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, b->vbo);
+
+ GLfloat rect[32];
+ memcpy(&rect, &default_rect, sizeof(GLfloat) * 32);
glBufferData(GL_ARRAY_BUFFER, 32 * sizeof(GLfloat), default_rect, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)0);
@@ -135,10 +138,18 @@ void create_block(struct block_drawable *b) {
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(6 * sizeof(GLfloat)));
glEnableVertexAttribArray(2);
- load_texture("block.jpg", b->texture);
+ load_texture(texture_file, b->texture);
+}
+
+void calc_size(GLfloat *rect, int x, int y) {
+ rect[0] = rect[8] = (x + 1.0f) / 10.0f;
+ rect[1] = rect[25] = (((y) * -1.0f) + 1.0f) / 20.0f;
+ rect[9] = rect[17] = rect[1] - .05f;
+ rect[16] = rect[24] = rect[0] - .1f;
}
-void update_block(struct block_drawable *b, int x, int y, int color) {
+
+void update_block(drawable *b, int x, int y, int color) {
GLfloat block[32];
memcpy(block, default_rect, sizeof(GLfloat) * 32);
@@ -185,8 +196,12 @@ int main(void) {
load_vertex_shader(shader_program);
glLinkProgram(shader_program);
- struct block_drawable block;
- create_block(&block);
+ drawable block;
+ create_static_2d(&block, 124, 124, "block.jpg");
+
+ drawable play_field;
+
+
cetris_game cetris;
init_game(&cetris);
diff --git a/frontends/gl/res/play_field.png b/frontends/gl/res/play_field.png
new file mode 100644
index 0000000..dee673b
--- /dev/null
+++ b/frontends/gl/res/play_field.png
Binary files differ
diff --git a/frontends/gl/res/play_field_shake_1.png b/frontends/gl/res/play_field_shake_1.png
new file mode 100644
index 0000000..4bbd0fb
--- /dev/null
+++ b/frontends/gl/res/play_field_shake_1.png
Binary files differ
diff --git a/frontends/gl/res/play_field_shake_2.png b/frontends/gl/res/play_field_shake_2.png
new file mode 100644
index 0000000..a5d5c20
--- /dev/null
+++ b/frontends/gl/res/play_field_shake_2.png
Binary files differ
diff --git a/frontends/gl/res/play_field_shake_3.png b/frontends/gl/res/play_field_shake_3.png
new file mode 100644
index 0000000..e26c21e
--- /dev/null
+++ b/frontends/gl/res/play_field_shake_3.png
Binary files differ
diff --git a/frontends/gl/res/play_field_shake_4.png b/frontends/gl/res/play_field_shake_4.png
new file mode 100644
index 0000000..399ecb8
--- /dev/null
+++ b/frontends/gl/res/play_field_shake_4.png
Binary files differ