Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeUnusualGames committed Sep 14, 2024
0 parents commit f12a74d
Show file tree
Hide file tree
Showing 44 changed files with 1,277 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ctypes_sh/
old/
Binary file added assets/graphics/bash_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/big_happy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/big_sad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/message1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/message2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/message_footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/sad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/tentacle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/tentacle2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/tentacle3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/tentacle4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/title2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/tux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/graphics/window1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/music/Oldschool_Action_Theme_Intro.mp3
Binary file not shown.
Binary file added assets/music/Oldschool_Action_Theme_Main.mp3
Binary file not shown.
Binary file added assets/music/Porkymon_Battle_Theme_Intro.mp3
Binary file not shown.
Binary file added assets/music/Porkymon_Battle_Theme_Main.mp3
Binary file not shown.
Binary file added assets/music/Speedier_Than_Photons.mp3
Binary file not shown.
Binary file added assets/music/game_over_bad_chest.wav
Binary file not shown.
Binary file added assets/music/winneris_0.ogg
Binary file not shown.
9 changes: 9 additions & 0 deletions credits.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Shiny window pane
https://opengameart.org/content/shiny-window-pane
Made by Fupi
CC0

Tux - Kyrodian Legends Style
Made by Kelvin Shadewing
https://opengameart.org/content/tux-kyrodian-legends-style
https://creativecommons.org/licenses/by-sa/4.0/
79 changes: 79 additions & 0 deletions game.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
function init_everything() {
init_window $1 $2 $3
dlcall InitAudioDevice

init_background 50
init_tux
load_tux_assets
init_window_boss
load_window_assets
init_title

struct -m render_texture_ptr RenderTexture render_texture
dlcall sh_LoadRenderTexture $render_texture_ptr int:1280 int:720
dlcall sh_SetTextureFilter $render_texture_ptr
}

function update_game() {
if $in_title; then
update_title
else
if ! $game_over && ! $player_won ; then
update_tux
update_window
else
update_music
if $game_over; then
tux_game_over_update
update_window_anim
elif $player_won; then
win_game_over_update
update_tux
fi
dlcall -n key_pressed -r bool IsKeyPressed int:82
if [[ $key_pressed == bool:1 ]]; then
restart_win
restart_tux
game_over=false
player_won=false
dlcall sh_PlayMusicStream $music_intro1_ptr
fi
fi
fi
}

function draw_game() {
dlcall sh_BeginTextureMode $render_texture_ptr
if $win_hard_mode; then
#begin_drawing int64:4292311040
dlcall ClearBackground int64:4292311040
draw_hard_mode_background
else
dlcall ClearBackground int64:4278190080
draw_background
fi

if $in_title; then
draw_title
else
draw_window
draw_tux
if $game_over; then
dlcall DrawText string:"Loser! Press R to reset" int:300 int:300 int:60 int64:4278190335
elif $player_won; then
dlcall DrawText string:"You won! Press R to reset" int:300 int:300 int:60 int64:4278255360
fi
dlcall DrawFPS int:0 int:0
dlcall DrawText string:"Victories: $victories Defeats: $defeats" int:1100 int:0 int:10 int64:4294967295
fi
dlcall EndTextureMode

begin_drawing int64:4278190080
dlcall sh_DrawRenderTexture $render_texture_ptr int:1280 int:720
end_drawing
}

#function unload_everything() {
# TODO: Unload stuff here
#}

42 changes: 42 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

# Exit immediately if a command exits with a non-zero status
set -e

# NOTE: The decimal point could be either a dot or a comma
# Save it to remove it from float variables
dec_pt=$(locale decimal_point)

if ! source ctypes.sh; then
echo "ctypes.sh not found, please install it: https://github.com/taviso/ctypes.sh/"
exit 1
fi

source raylib.sh
source utils.sh
source space_background.sh
source tux.sh
source window.sh
source title.sh
source game.sh

include_files
init_everything 1280 720 Tux-Vs-Mutant-Window

in_title=true
game_over=false
player_won=false
victories=0
defeats=0

while true; do
update_game
draw_game
dlcall -n should_close -r bool WindowShouldClose
if [[ $should_close == bool:1 ]]; then
break
fi
done

dlcall CloseAudioDevice
dlcall CloseWindow
7 changes: 7 additions & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
It would be great to have a function to turn a float to int and vice versa
float:3.141592 -> int:3

Also something that performs integer arithmetic to a float
float:3.141592 + 10 => float:13.141592

Several things are frame dependant...
18 changes: 18 additions & 0 deletions raylib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set -e

function init_window() {
# FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE
dlcall SetConfigFlags int:68
dlcall InitWindow int:$1 int:$2 string:$3
dlcall SetTargetFPS int:60
dlcall SetWindowMinSize int:320 int:240
}

function begin_drawing() {
dlcall BeginDrawing
dlcall ClearBackground $1
}

function end_drawing() {
dlcall EndDrawing
}
Binary file added raylib/libraylib.so.5.0.0
Binary file not shown.
35 changes: 35 additions & 0 deletions raylib/music_fun.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "raylib.h"
#include <stdbool.h>
#include <stdlib.h>

void sh_LoadMusicStream(Music *music, char *path, int loop)
{
*music = LoadMusicStream(path);
music->looping = loop == 1 ? true : false;
}

void sh_PlayMusicStream(Music *music)
{
PlayMusicStream(*music);
}

void sh_UpdateMusicStream(Music *music)
{
UpdateMusicStream(*music);
}

void sh_StopMusicStream(Music *music)
{
StopMusicStream(*music);
}

void sh_UnloadMusicStream(Music *music)
{
UnloadMusicStream(*music);
free(music);
}

int sh_IsMusicStreamPlaying(Music *music)
{
return IsMusicStreamPlaying(*music) ? 1 : 0;
}
Binary file added raylib/music_fun.so
Binary file not shown.
25 changes: 25 additions & 0 deletions raylib/rectangle_fun.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "raylib.h"

void newRect(Rectangle *rec, float x, float y, float width, float height)
{
rec->x = x;
rec->y = y;
rec->width = width;
rec->height = height;
}

void sh_DrawRectangleRec(Rectangle *rec, Color color)
{
//printf("%f %f %f %f\n", rec->x, rec->y, rec->width, rec->height);
DrawRectangleRec(*rec, color);
}

void sh_DrawRectangleLines(int x, int y, int width, int height, float thick, Color tint)
{
DrawRectangleLinesEx((Rectangle){x, y, width, height}, thick, tint);
}

int sh_CheckCollisionPointRec(int x, int y, int recX, int recY, int width, int height)
{
return CheckCollisionPointRec((Vector2){x, y}, (Rectangle){recX, recY, width, height}) ? 1 : 0;
}
Binary file added raylib/rectangle_fun.so
Binary file not shown.
37 changes: 37 additions & 0 deletions raylib/rendertexture_fun.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "raylib.h"

#define MAX(a, b) ((a)>(b)? (a) : (b))
#define MIN(a, b) ((a)<(b)? (a) : (b))

void sh_LoadRenderTexture(struct RenderTexture *texture, int width, int height)
{
//texture = malloc(sizeof(Texture2D));
*texture = LoadRenderTexture(width, height);
//return texture;
}

void sh_BeginTextureMode(struct RenderTexture *texture)
{
BeginTextureMode(*texture);
}

void sh_SetTextureFilter(struct RenderTexture *target)
{
SetTextureFilter(target->texture, TEXTURE_FILTER_BILINEAR);
}

void sh_DrawRenderTexture(struct RenderTexture *target, int gameScreenWidth, int gameScreenHeight)
{
float scale = MIN((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight);
DrawTexturePro(
target->texture,
(Rectangle){ 0.0f, 0.0f, (float)target->texture.width, (float)-target->texture.height },
(Rectangle){
(GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5f,
(GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5f,
(float)gameScreenWidth*scale, (float)gameScreenHeight*scale
},
(Vector2){ 0, 0 },
0.0f, WHITE
);
}
Binary file added raylib/rendertexture_fun.so
Binary file not shown.
26 changes: 26 additions & 0 deletions raylib/texture_fun.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "raylib.h"

void sh_LoadTexture(struct Texture *texture, char *filename)
{
*texture = LoadTexture(filename);
}

void sh_DrawTexture(Texture2D *texture, int x, int y, Color color)
{
DrawTexture(*texture, x, y, color);
}

void sh_DrawTexturef(Texture2D *texture, float x, float y, Color color)
{
DrawTexture(*texture, (int)x, (int)y, color);
}

void sh_DrawTexturePro(Texture2D *texture, Rectangle *source, Rectangle *dest, Vector2 *origin, float rotation, Color tint)
{
DrawTexturePro(*texture, *source, *dest, *origin, rotation, tint);
}

void sh_DrawTextureV(Texture2D *texture, Vector2 *position, Color tint)
{
DrawTextureV(*texture, *position, tint);
}
Binary file added raylib/texture_fun.so
Binary file not shown.
62 changes: 62 additions & 0 deletions raylib/utils.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "raylib.h"
#include <math.h>

// For some reason this function returns garbage even though IsKeyPressed works fine,
// so as a workaround use int instead of bool
int sh_IsKeyDown(int key)
{
return IsKeyDown(key) ? 1 : 0;
}

// Framerate independent lerp function, yoink'd from Freya Holmér
// https://youtu.be/LSNQuFEDOyQ
float lerp(float a, float b, float decay, float dt)
{
return b+(a-b)*expf(-decay*dt);
}

float add_position(float pos, float speed, float dt)
{
return pos + speed*dt;
}

int add_position_i(int pos, float speed, float dt)
{
return (int)add_position((float)pos, speed, dt);
}

float sub_position(float pos, float speed, float dt)
{
return pos - speed*dt;
}

float sub_position_cos_angle(float pos, float angle, float speed, float dt)
{
return pos - cosf(angle)*speed*dt;
}

float sub_position_sin_angle(float pos, float angle, float speed, float dt)
{
return pos - sinf(angle)*speed*dt;
}


int sub_position_i(int pos, float speed, float dt)
{
return (int)sub_position((float)pos, speed, dt);
}

float deg2rad(float degrees)
{
return degrees*DEG2RAD;
}

float angle_points(float x1, float y1, float x2, float y2)
{
return atan2(y1-y2, x1-x2);
}

int check_collision(Rectangle *rec1, Rectangle *rec2)
{
return CheckCollisionRecs(*rec1, *rec2) ? 1 : 0;
}
Binary file added raylib/utils.so
Binary file not shown.
Loading

0 comments on commit f12a74d

Please sign in to comment.