Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into next
  • Loading branch information
bitten2up committed Sep 1, 2024
2 parents 48ced53 + a9ee73a commit 4fe8459
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 20 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build ubuntu

on:
push:
branches: [ master ]
branches: [ next, master ]
pull_request:
branches: [ next, master ]

Expand All @@ -17,8 +17,8 @@ jobs:
with:
toolchain: stable
- name: install x11-dev
run: sudo apt install libxi-dev libxinerama-dev libxcursor-dev -y
- name: install Raylib
run: git clone https://github.com/raysan5/raylib; cd raylib/src; make;
run: sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libz-dev libxml2-dev libopengl-dev
- name: install libtmx
run: git clone https://github.com/baylej/tmx && cd tmx && mkdir build && cd build && cmake .. && make -j4 && sudo make install
- name: Compile
run: make RAYLIB_PATH=./raylib -B;
run: mkdir build && cd build && cmake .. && make;
32 changes: 32 additions & 0 deletions docs/levels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# bitten engine level format

## tiled is nice and all, but can be a bitch at times

I would like to minimize dependices to make it easier to port, not to mention just how badly undocumented it is. Just look at `e_collision.c` for example, fucking gross. Better yet it doesn't even work properly still.... (worse part it worked on raylib iirc)
The other issue is that if i can bearly get collision working with static objects because welp look at that, fucking conversions to get our current location that not even I understand how they worked back in the raylib days (when they actually somewhat worked properly, iirc i even could delete tiles or smth)

## Why not use LDtk

well.. if you looked through `r_render.c` you can find broken code to attempt and do this exact thing, but iirc i didn't like any of the libraries for it. now that I have cpp, i might consider it again though.

## the plan

make something thats easy to use. one of the goals is being able to figure out if we are coliding at different aspect ratios/resolutions and be able to have the character not be dead stuck in the middle of the screen


## ok but what's the catch

well... inorder to do that, i don't want to just remove whats currently working, so I will make a simple map configuration format that will define which format to use.

the goal would be something like this for the time being

```text
version 1
using tiled/LDtk/custom
```

now i dont feel like parsing text, so ill take the easy way out for now

```c
char file[] = {'0x1', '0x0'} // first value is version, second is format (in this case tiled)
```
23 changes: 23 additions & 0 deletions docs/savefiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# bitten engine save files

## file format

to start out with, I'll show the code that defines the default save as of july 9th 2024
```c
enum saveFormat
{
HEADER = 0,
HEADERVERSION = 10,
SETTINGS = 11,
SAVEDXPOS = 12,
SAVEDYPOS = 16,
};
unsigned char saveD[] = {
'b', 'i', 't', 't', 'e', 'n', 's', 'a', 'v', 0x00, // header, last byte is for different games
0x00, // version of save format, part of header, but we check this separately
0b10000000, // first value: music, second value: fullscreen
0x00, 0x00, 0x00, 0x00, // x position
0x00, 0x00, 0x00, 0x00, // y position
};
unsigned int saveDlen = 20;
```
20 changes: 10 additions & 10 deletions src/bit_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@

extern "C"
{
#include "sdl_bittendef.h"
#include "bit_game.h"
#include "r_render.h"
#include "i_event.h"
#include "e_entity.h"
#include "bit_game.h"
#include "p_player.h"
#include "b_battle.h"
#include "e_collision.h"
#include "f_save.h"
#include "sdl_bittendef.h"
#include "bit_game.h"
#include "r_render.h"
#include "i_event.h"
#include "e_entity.h"
#include "bit_game.h"
#include "p_player.h"
#include "b_battle.h"
#include "e_collision.h"
#include "f_save.h"
}

void bit_main()
Expand Down
3 changes: 3 additions & 0 deletions src/bittendef.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
/*
* this file toggles debugging and release flags for the game
*/

// unused file because `sdl_bittendef.h` ended up replacing it.

#ifndef BITTENDEF_H
#define BITTENDEF_H
#include <stdbool.h>
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
* SOFTWARE.
*/

#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
//#include <cLDtk.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "discord.h"

//#include <cLDtk.h>

extern "C"
{
#include "bit_game.h"
Expand Down
3 changes: 2 additions & 1 deletion src/r_render.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
* SOFTWARE.
*/

#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>

#include <tmx.h>
#include <cLDtk.h>
#include <stdio.h>

#include "sdl_bittendef.h"
#include "r_render.h"
Expand Down
4 changes: 2 additions & 2 deletions src/sdl_bittendef.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
//#include "raylib.h"
#include "tmx.h"
// set the title of the game
#define GAME_NAME "bittens adventure"
Expand All @@ -40,12 +39,12 @@
#else
#define PATCH_DLL "libbit-patch.so"
#endif
//#define DISCORD // Enables discord rpc, use MAKE DISCORDRPC=TRUE to compile with this flag

// files
#ifndef PLATFORM_WEB
#define SAVE_FILE "bitten.sav"
#endif

// TODO make this editable in an settings menu
#define SCREENWIDTH 800
#define SCREENHEIGHT 450
Expand All @@ -56,6 +55,7 @@
////////////////////////////////////////////////////////////
#define BIT_VERSION 0x01

// should be moved elsewhere
////////////////////////////////////////////////////////////
// tmx layers with names emum
////////////////////////////////////////////////////////////
Expand Down
40 changes: 40 additions & 0 deletions src/t_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* MIT License
*
* Copyright (c) 2021-2024 bitten2up
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

/////////////////////////////
/*
* t_main.cpp
*
* handles reading the tilemaps data.
*/
/////////////////////////////

#include "tmx.h"
#include <cLDtk.h>


extern "c" {
#include "t_main.h"
}
23 changes: 23 additions & 0 deletions src/t_main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* MIT License
*
* Copyright (c) 2021-2024 bitten2up
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

0 comments on commit 4fe8459

Please sign in to comment.