Coder Social home page Coder Social logo

diab-concept's Introduction

Conceptual tester for DiaB

Now that this is public I guess it needs an actual readme! This is just a repo to test out game engine stuff for a game idea I've had for years, that I've titled Death is a Blessing.

I'd also like to get advice from people about how to proceed with certain issues.

Tech Stack

I'm using:

Running the game

  1. Grab your relevant file from the releases
  2. Change the permissions on it with chmod +x [FILENAME]
  3. You should be good to go!

Developing the game/build from source

  1. Install zig
  2. Fetch zig-raylib (from within the repo)
    • zig fetch --save https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz
  3. zig build run

I try to leave the main branch in a state where it'll always compile and run, but that's not guaranteed tbqh.

diab-concept's People

Contributors

boundlesscarrot avatar

Watchers

 avatar

diab-concept's Issues

Make the arena have a set shape

Screen borders work but they're not the end goal - what I want is for there to be a set shape with corners, maybe even columns, where the player can even get stuck

Allow for random drops

Will likely be a big shift, but when an enemy dies I'd like there to be a chance that a item drop happens, with effects either to the player (movement wise), the weapon, or the arena

Enemies spawn without shooting

Current issue is that collision checking is now decoupled from shooting, and the shot isn't instantaneous anymore. This means the CollisionEvent in the main game loop will almost always be false, which triggers doMissEvent which in turn spawns enemies.

A.C.

  • have enemies spawn only once a projectile gets a set distance away from the player
  • Add a condition to enemy spawning in doMissEvent?

Terminal window opens when game opens

When playing a release version, opening the game causes a terminal window to also open with some raylib boot and diagnostic info. This should not happen.

Any hit or miss causes the game to crash

The current system basically gets CollisionEvents for all applicable events and puts them in a dynamic array. We then iterate over this array and perform doCollisionEvent or doMissEvent on the event particulars (the loop code that controls this can be seen here). Those funcs are below:

pub fn doCollisionEvent(numCollisions: *usize, enemyList: *std.ArrayList(raylib.Rectangle), projectiles: *std.ArrayList(Projectile), collision: CollisionEvent) void {
    numCollisions.* += 1;

    _ = projectiles.orderedRemove(collision.proj_idx);
    _ = enemyList.orderedRemove(collision.rec_idx);
}

// TODO: only spawn enemies if the shot missed and hit the edge of the screen (or a certain distance away from the player)
pub fn doMissEvent(activeEvent: CollisionEvent, enemyList: *std.ArrayList(raylib.Rectangle), projectileList: *std.ArrayList(Projectile)) !void {
    try spawnEnemy(activeEvent.point, enemyList);
    _ = projectileList.orderedRemove(activeEvent.proj_idx);
}

However, any time the player hits or misses it causes the game to crash. These errors are below:

on miss:

Collision event: gameAPI.CollisionEvent{ .bool = false, .point = raylib.Vector2{ .x = 0e0, .y = 0e0 }, .rec_idx = 4, .proj_idx = 0 }
thread 126201 panic: index out of bounds: index 0, len 0
/usr/local/Cellar/zig/0.13.0/lib/zig/std/array_list.zig:282:40: 0x10a3ef650 in orderedRemove (DiaB-concept)
            const old_item = self.items[i];
                                       ^
/Users/jordans/projects/mach-mess/src/gameAPI.zig:240:37: 0x10a3ef56f in doMissEvent (DiaB-concept)
    _ = projectileList.orderedRemove(activeEvent.proj_idx);
                                    ^
/Users/jordans/projects/mach-mess/src/main.zig:160:43: 0x10a3ecc61 in main (DiaB-concept)
                    } else try doMissEvent(collision, &enemyList, &projectileList);
                                          ^
/usr/local/Cellar/zig/0.13.0/lib/zig/std/start.zig:524:37: 0x10a3ebf8b in main (DiaB-concept)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7ff8060353a5 in ??? (???)
Unwind information for `???:0x7ff8060353a5` was not available, trace may be incomplete

???:?:?: 0x0 in ??? (???)
run
└─ run DiaB-concept failure

on hit:

Collision event: gameAPI.CollisionEvent{ .bool = true, .point = raylib.Vector2{ .x = 1.0689075e2, .y = 1.12681305e2 }, .rec_idx = 1, .proj_idx = 0 }
thread 129194 panic: index out of bounds: index 1, len 1
/usr/local/Cellar/zig/0.13.0/lib/zig/std/array_list.zig:282:40: 0x109580a50 in orderedRemove (DiaB-concept)
            const old_item = self.items[i];
                                       ^
/Users/jordans/projects/mach-mess/src/gameAPI.zig:232:32: 0x109554ce6 in doCollisionEvent (DiaB-concept)
    _ = enemyList.orderedRemove(collision.rec_idx);
                               ^
/Users/jordans/projects/mach-mess/src/main.zig:159:41: 0x109550c41 in main (DiaB-concept)
                        doCollisionEvent(&numCollisions, &enemyList, &projectileList, collision);
                                        ^
/usr/local/Cellar/zig/0.13.0/lib/zig/std/start.zig:524:37: 0x10954ff8b in main (DiaB-concept)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7ff8060353a5 in ??? (???)
Unwind information for `???:0x7ff8060353a5` was not available, trace may be incomplete

???:?:?: 0x0 in ??? (???)
run
└─ run DiaB-concept failure

The correct behavior would be:

  • On hit the enemy would be removed from the enemyList and the projectile that hit it would be removed from the projectileList
  • On miss the projectile would reach the edge of the screen and spawn 1..5 enemies at the spot where it passed into the out-of-bounds area. This would also include removing the projectile from the projectileList and adding the enemies to the enemyList

Handle 2 projectiles hitting at (almost) the same time

If many projectiles hit enemies at the same time, we have no way of handling that - we simply break the collision detection loop at the first hit and just return that single CollisionEvent

Maybe returning an array (more likely ArrayList) of CollisionEvents is the best path?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.