-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from abdothegreat/main
[EXAMPLE] Moving Square
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 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,29 @@ | ||
cmake_minimum_required(VERSION 3.18) | ||
|
||
project(Muzzle) | ||
INCLUDE_DIRECTORIES(../../include) | ||
LINK_DIRECTORIES(../../deps/glfw/lib) | ||
set(mz_source_dir "../../src") | ||
|
||
#could use aux_source_directory() but its better to list each file to ensure new files are compiled | ||
#https://stackoverflow.com/a/25077976/10415312 | ||
|
||
|
||
set(mz_source | ||
${mz_source_dir}/Applet.c | ||
${mz_source_dir}/callback.c | ||
${mz_source_dir}/Drawing.c | ||
${mz_source_dir}/Error.c | ||
${mz_source_dir}/Loop.c | ||
${mz_source_dir}/Muzzle.c | ||
${mz_source_dir}/Rectangle.c | ||
${mz_source_dir}/tint.c | ||
${mz_source_dir}/Circle.c | ||
${mz_source_dir}/Input.c | ||
${mz_source_dir}/Sprite.c | ||
${mz_source_dir}/Text.c | ||
) | ||
|
||
|
||
add_executable(main src/main.c ${mz_source}) | ||
TARGET_LINK_LIBRARIES(main glfw3 opengl32 gdi32) |
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,7 @@ | ||
mkdir build | ||
cd build | ||
cmake .. -G "MinGW Makefiles" | ||
mingw32-make | ||
.\main.exe | ||
cd .. | ||
rm build |
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,39 @@ | ||
#define MUZZLE_DEPS | ||
#include <Muzzle.h> | ||
#include <stdio.h> | ||
#define SCREEN_WIDTH 500 | ||
#define SCREEN_HEIGHT 500 | ||
|
||
Applet applet; | ||
|
||
void OnAppletUpdate() | ||
{ | ||
rectangle player = { | ||
.height = 50, | ||
.width = 50, | ||
.x = 225, | ||
.y = 225 | ||
}; | ||
|
||
while (keep_applet(applet.window_handle)) | ||
{ | ||
begin_drawing(); | ||
clear_screen(GRAY); | ||
if(key_down(&applet, KEY_W)&&player.y!=5) player.y -=5; | ||
else if(key_down(&applet, KEY_S)&&player.y!=495&&player.y!=490) player.y +=5; | ||
else if(key_down(&applet, KEY_A)&&player.x!=5) player.x -=5; | ||
else if(key_down(&applet, KEY_D)&&player.x!=495&&player.x!=490) player.x +=5; | ||
draw_rectangle_rec(player,WHITE); | ||
end_drawing(&applet); | ||
} | ||
|
||
} | ||
|
||
int main(void) | ||
{ | ||
applet = InitializeApplet(SCREEN_WIDTH, SCREEN_HEIGHT, "Muzzle [EXAMPLE] - Movable Square", MUZZLE_FALSE, MUZZLE_TRUE); | ||
StartApplet(&applet); | ||
|
||
QuitMuzzle(applet); | ||
return 0; | ||
} |