Commit 02a78305 authored by Benjamin REED's avatar Benjamin REED

first commit!

parents
Pipeline #3029 failed with stages
# LARUTAN
LARUTAN (Natural backwards) is a raycasting game in the style of Wolfenstein 3D inspired (the rendering code is entirely copied in fact) by the tutorial by [https://lodev.org/cgtutor/raycasting.html](Lodev). The game is implemented in [https://c3-lang.org](C3), which is a work-in-progress evolution of the C language with built-in vectors and cool macro stuff.
LARUTAN (NATUREL à l'envers) est un jeu de 'raycasting' dans le style de Wolfenstein 3D, inspiré (en très grande partie, notamment pour le rendu graphique) par le tutoriel de [https://lodev.org/cgtutor/raycasting.html](Lodev). Le jeu est écrit en [https://c3-lang.org](C3), une évolution du langage C avec support pour des vecteurs multi-dimensionnels et de la magie avec les macros qui n'est pas disponible en C.
# Controls
ZQSD (WASD) to move around (ZS/WS to move backwards and forwards, QD/AD to turn), hold LEFT-ALT to strafe (move from side to side), and space (TODO) to fire with the weapon you're currently holding.
# Building
In order to build LARUTAN you will need the C3 compiler, which can be found on the [https://c3-lang.org/install-c3/prebuilt-binaries/](c3 website). Follow that tutorial and once you have the compiler installed (no worries if its in the same directory as the project, that may make things easier, especially if you get a problem with finding the standard library).
You will also need raylib 5.0, which can be found on the [](raylib website), although I reccommend finding the binaries in the [https://github.com/raysan5/raylib/releases](github releases page) and installing them in the same directory as this folder. My file structure looks like this:
```
*-- LARUTAN
|
\-- src/
\-- raylib-5.0\
|
\-- lib/
|
\-- libraylib.so.500
\-- ...
\-- include
\-- ...
\-- ...
```
If you installed raylib under a different name then edit the makefile to take this into account, change the variable ```RAYLIB_LIBRARY_SEARCH_PATH``` to the name of your folder containing raylib binaries. If you installed c3 into this directory, then set the ```C3_STD``` variable to be empty.
Then just run make and hope for the best. Linker errors will be something to do with the folders being called the wrong thing. If you can't get it to work, try just using c3c.
Your command should look something like this:
```
user$ c3c compile-run src/*.c3 -lraylib -L<your path to raylib's binaries>
```
If you have any further issues, please open an issue.
# NOTES
The project is in its very early stages... not many things work but the very basic engine. Plans are to optimise (very slow) and add real gameplay, notably using weapons, picking up weapons, enemy ai that works, and a physics implementation that isn't simply: 'try everything against everything else and hope for the best.' Thank you for your patience.
# CREDITS
Credit for brick wall texture: [https://www.the3rdsequence.com/texturedb/texture/9/brick+wall/](TODO: find this person's name)
TODO:
- Version française.
File added
RAYLIB_LIBRARY_SEARCH_PATH = ./raylib-5.0/lib
RAYLIB_LIB_NAME = raylib
C3_STD = --stdlib /usr/local/lib
OUTPUT_NAME = main
fast: src/main.c3
c3c compile src/*.c3 -O3 -l $(RAYLIB_LIB_NAME) -L $(RAYLIB_LIBRARY_SEARCH_PATH) $(C3_STD) -o $(OUTPUT_NAME)
run: main
./$(OUTPUT_NAME)
main: src/main.c3
c3c compile src/*.c3 -l $(RAYLIB_LIB_NAME) -L $(RAYLIB_LIBRARY_SEARCH_PATH) $(C3_STD) -o $(OUTPUT_NAME)
clean:
rm $(OUTPUT_NAME)
This diff is collapsed.
import std::math;
struct Rect {
float x, y, w, h;
}
enum RectCorner {
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT,
}
const Rect ZERO = {0, 0, 0, 0};
macro bool Rect.equals(Rect *this, Rect that) {
return this.x == that.x && this.y == that.y && this.w == that.x && this.h == that.h;
}
fn bool Rect.contains(Rect this, Vec2 point) {
return
(float)point.x >= this.x &&
(float)point.y >= this.y &&
(float)point.x <= (this.x + this.w) &&
(float)point.y <= (this.y + this.h);
}
fn bool Rect.contains_rect(Rect this, Rect other) {
Vec2 tl = other.corner(RectCorner.TOP_LEFT);
Vec2 tr = other.corner(RectCorner.TOP_RIGHT);
Vec2 bl = other.corner(RectCorner.BOTTOM_LEFT);
Vec2 br = other.corner(RectCorner.BOTTOM_RIGHT);
return
this.contains(tl) ||
this.contains(tr) ||
this.contains(bl) ||
this.contains(br);
}
fn Rect Rect.intersection(Rect this, Rect other) {
// TODO: write working intersection check
if (!this.contains_rect(other)) {
return {0, 0, 0, 0};
}
float left = math::max(this.x, other.x);
float width = math::min(this.x + this.w, other.x + other.w) - left;
float top = math::max(this.y, other.y);
float height = math::min(this.y + this.h, other.y + other.h) - top;
return Rect { left, top, width, height };
}
fn Vec2 Rect.corner(Rect this, RectCorner corner) {
switch (corner) {
case RectCorner.TOP_LEFT:
return {this.x, this.y};
case RectCorner.BOTTOM_LEFT:
return {this.x, (double)(this.y + this.h)};
case RectCorner.BOTTOM_RIGHT:
return {(double)(this.x + this.w), (double)(this.y + this.h)};
case RectCorner.TOP_RIGHT:
return {(double)(this.x + this.w), this.y};
}
}
import std::math;
import math;
const int KEY_S = 83;
const int KEY_W = 87;
const int KEY_D = 68;
const int KEY_A = 65;
const int KEY_SPACE = 32;
const int KEY_LEFT_ALT = 342;
const int KEY_RIGHT_ALT = 346;
def Colour = char[<4>];
// Raylib Image struct
struct Image {
char[<4>] *data; // Image raw data
int width; // Image base width
int height; // Image base height
int mipmaps; // Mipmap levels, 1 by default
int format; // Data format (PixelFormat type)
}
struct Texture {
uint id; // OpenGL texture id
int width; // Texture base width
int height; // Texture base height
int mipmaps; // Mipmap levels, 1 by default
int format; // Data format (PixelFormat type)
}
struct NPatchInfo {
Rect source; // Texture source rectangle
int left; // Left border offset
int top; // Top border offset
int right; // Right border offset
int bottom; // Bottom border offset
int layout; // Layout of the n-patch: 3x3, 1x3 or 3x1
}
extern fn void init_window(int width, int height, char* title) @extern("InitWindow");
extern fn void close_window() @extern("CloseWindow");
extern fn bool window_should_close() @extern("WindowShouldClose");
extern fn void begin_drawing() @extern("BeginDrawing");
extern fn void end_drawing() @extern("EndDrawing");
extern fn void clear_background(Colour color) @extern("ClearBackground");
extern fn void draw_rectangle(int posX, int posY, int width, int height, Colour color) @extern("DrawRectangle");
fn void draw_rect(Rect rect, Colour colour) {
draw_rectangle((int)rect.x, (int)rect.y, (int)rect.w, (int)rect.h, colour);
}
extern fn void draw_line_ex(Vec2 startPos, Vec2 endPos, float thick, Colour color) @extern("DrawLineEx");
extern fn void draw_line_v(Vec2 startPos, Vec2 endPos, Colour color) @extern("DrawLineV");
extern fn void draw_line(int startPosX, int startPosY, int endPosX, int endPosY, Colour color) @extern("DrawLine");
extern fn void draw_grid(int slices, float spacing) @extern("DrawGrid"); // Draw a grid (centered at (0, 0, 0))
extern fn float get_frame_time() @extern("GetFrameTime");
extern fn void set_target_fps(int max_fps) @extern("SetTargetFPS");
extern fn bool is_key_pressed(int key) @extern("IsKeyPressed");
extern fn bool is_key_down(int key) @extern("IsKeyDown");
extern fn Image gen_image_colour(int width, int height, Colour color) @extern("GenImageColor"); // Generate image: plain color
extern fn Image load_image(char* file_path) @extern("LoadImage");
extern fn Image load_image_from_memory(char *fileType, char *fileData, int dataSize) @extern ("LoadImageFromMemory");
extern fn Image load_image_from_screen() @extern("LoadImageFromScreen"); // Load image from screen buffer and (screenshot)
extern fn void update_texture(Texture texture, char *pixels) @extern("UpdateTexture"); // Update GPU texture with new data
extern fn Texture load_texture_from_image(Image image) @extern("LoadTextureFromImage"); // Load texture from image data
extern fn void draw_texture(Texture texture, int posX, int posY, Colour tint) @extern("DrawTexture");
extern fn void unload_texture(Texture texture) @extern("UnloadTexture");
extern fn void draw_texture_with_params(Texture texture, NPatchInfo nPatchInfo, Rect dest, Vec2 origin, float rotation, Colour tint) @extern("DrawTextureNPatch"); // Draws a texture (or part of it) that stretches or shrinks nicely
extern fn void unload_image(Image image) @extern("UnloadImage");
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment