stardance has been extended another month! the new deadline is october 31 :)

You are browsing as a guest. Sign up (or log in) to start making projects!

nano

@nano

Joined July 22nd, 2026

  • 37Devlogs
  • 3Projects
  • 3Ships
  • 38Votes
Basically only know C, really into operating systems and CE!
Ship Pending review

A suckless complete CHIP-8 emulator written in C!

What is in it?

  • All instructions the original CHIP-8 architecture supported
  • Graphical output to the terminal using (my beloved) ncurses
  • Loading .ch8 roms
  • Error handling with stderr

What am I proud of?

I am really proud of the optimizations i did for the project after pretty much finishing it. I am also proud of the way i implemented the keyboard (which was really hard) and the way it turned out. I am also proud of the error handling because it helped me level up in my overall knowledge in knowing how to handle errors.

How is it built?

It’s built in C using ncurses, following the suckless philosophy (optimized and only one source file) and most of the suckless style guide. There is a precompiled binary that was built with GitHub workflows using Ubuntu. The binary can be directly downloaded from the repo’s release page and can be used on (most) glibc-based Linux distros (build is compiled for Ubuntu and ncurses-v6 has to be installed on your system, original project was made with NixOS, which will also work).

What I learned

I learned how CPU’s operate (fetch, decode, execute), i learned about opcodes and parsing and i learned using bitwise operators effectively. It also taught me the importance of hexadecimal in programming. The project overall brought me closer to CompEng and how CPU’s work on a rudimentary level. It also taught me (as said) how to handle errors better and i think because of trying to make the project as suckless as possible the project also made me an overall better programmer.

Known limitations / plans for the future

Bugs can occur, even though no error that isn’t being handled by the program itself has been recorded. Still look out for bugs and if any are found write it to me as feedback please.

As this project is a full emulator for CHIP-8 there isn’t that much to be done anymore which i am really proud of :)

Closing word

This project was pretty fun to make and it taught me a bunch. It is also my final project for Stardance which is a bit sad but i don’t/didn’t have enough time to start a new project which is why i will stop with this. Still i loved Stardance and it brought me closer to CE/SE than i would ever think i would get (before hearing of Stardance i wasn’t really fond of coding). To anyone reading this whole thing: Love y’all :)))

  • 5 devlogs
  • 12h
Try project → See source code →
Open comments for this post

2h 21m 27s logged

LOG 5: LAST LOG BEFORE SHIP, MADE THE PROJECT MOSTLY SUCKLESS,

REWORKED KEYBOARD, ADDED A DIE FUNCTION, ROMS ARE NOW LOADED VIA
TERMINAL, ADDED MACROS, ADDED README

FEATURES

“SUCKLESS”

I made the program (i think) as much compliant to the suckless philosophy as i can and did most of (not all of) the stylistic choices mentioned in the suckless style guide. I think making it suckless majorly improved the program

KEYBOARD REWORK

Because i decided i wanted to make the project basically suckless i have decided that i needed to rework the keyboard functions. I replaced the keyboard struct with long long keyboard[16]. The index is now the key and the value is the value that key_pressed compares against when the instrcutions are called. key_pressed returns (now - keypad[k]) < ACCEPTABLE_DISTANCE which made the logic way smaller and easier to read. I also replaced the ~ 60 lines key switch statement with a single array that has all the characters of the Chip-8 keyboard and compares it using strchr with the input ch and the difference between the return value of strchr and the positon of keyboard[0] is the index which the current time is written into

DIE FUNCTION

I added a die function that replaces all early exit functions that would kill the entire program. It gets an input string and other parameters (like printf would get) and print it to stderr. It does this by using varargs. If initscr() has been called it also does endwin() and if not it doesnt (a bool is turned to true after initscr() has been called). Because of this read_rom is now void because every error path calls die instead of returning false. fopen also calls strerror if it fails to display WHY fopen has failed

TERMINAL INPUT

Previously rom names were hardcoded into the program and had to be changed and recompiled if i wanted to change them. Now the program takes in multiple arguments (2 in total, more or less results in an error after which the proper usage is displayed) and the rom (if found) is copied and executed which makes testing multiple programs way easier.

MACROS

I removed magic number and replaced them with macros to make the code more readable and theoretically modifiable.

README

I added a README in the repo that explains pretty much everything that you would need to know before using the program

0
0
16
Open comments for this post

2h 2m 51s logged

LOG 4: KEYBOARD IS FINALLY FUNCTIONAL FOR (hopefully) ALL INSTRUCTIONS!!!! (and some bug fixes)

After a long battle with the code i finally figured out how to implement the keyboard without the keys only being picked up every once in a while.

HOW DID I DO IT?

Previously the keyboard was simple a bool array and if i a button was pressed the corresponding part of the keypad array was turned true. The issue with that was that with this simple implementation there had to be one of 2 mandatory pay-offs: Case A would be that the keys would be sticky and never get turned false, Case B would be that they get reset on every iteration of the main loop which is too fast for instructions 0x9E and 0xA1 in certain programs, as they need the value for multiple iterations. Simply holding down the key was actually too slow because of the way holding down a key works on linux which is why i had to do the following implmentation:

Step A:

  • Get the current pressed button, turn it to true and save the time the button was pressed

Step B:

  • Get the time distance between when the button was pressed and the current time .
  • Loop through the keyboard array and check for keys that are true
  • If a key is true and if the time distance is larger/equal than/to the threshold (50 ms), turn that key false.
  • Following from this if the distance is smaller or equal to the acceptable distance the key stays true and the loop can work with it.

BUG FIXES

ISSUE WITH INSTRUCTION 0x8xy6 and 0x8xyE

Previously 0x8xy6 and 0x8xyE bitshifted chip.v_reg[x] either « 1 or » 1 which i found out was false after rereading the docs because a test code wasnt working properly. The fix was just to implement the correct instruction (chip.v_reg[x] = chip.v_reg[y] « 1 or the same using » 1)

0
0
12
Open comments for this post

3h 31m 25s logged

LOG 3: ROM LOADER, GRAPHICS ENGINE, KEYBOARD, FONTSET, TEST CODE

FOREWORD

FEATURES

I kinda didnt click post on my last devlog which is why this is a combination of two devlogs but ig this has to suffice

ROM LOADER

I implemented a rom loader that opens and copies roms (.ch8 files) and then executes their instructions when the program runs. The rom reader opens the file with fopen and reads them into memory using fread once.

GRAPHICS ENGINE

I use my (beloved) ncurses for graphics and a function is called every cycle to print out the graphics on the 64x32 screen using either # for spots where the graphic display is true and ’ ’ for spots where it isnt

KEYBOARD

The keyboard uses getch that doesnt stop the loop but rather just listens for input and then sets the keyboard value of the pressed button to true

FONTSET

The fontset is pretty basic (its just an array of the standard chip-8 fontset that gets loaded into the memory array starting from 0x50)

TEST CODE

Ive written some very basic test code for testing purposes. Current functions are printing to the screen, setting variables and printing when a button is pressed. I coded the code in hex and used hexed.it to convert the hex code into .ch8 files

BUG FIXES

Luckily there where no major bugs previously in the code (there wasnt that much to be buggy) but obviously there where issues on the way to the current code. Because i dont remember everything i fixed on the way i wont list it in todays devlog (overall i just list bugs if they where in a previious commited/devlogged version)

0
0
19
Open comments for this post

3h 0m 51s logged

LOG 2: KNOWING WHAT TO DO, IMPLEMENTED ALL INSTRUCTIONS

WHAT KIND OF CPU AM I BUILDING?

I am building a CHIP-8 CPU emulator in C based on the specifications at http://devernay.free.fr/hacks/chip8/C8TECH10.HTM.

CURRENT FEATURES

Currently i have implemented all of the regular CHIP-8 instructions that are listed on the source website. They are detected by checking for the specific flags and then execute code based on their variables. There are a total amount of 33 instructions available (normally there are 34 for CHIP-8 but one isn’t used in emulators). Currently the CPU cannot take instructions (will be implemented next probably)

0
0
27
Open comments for this post

1h 11m 2s logged

LOG 1: MY OWN CPU EMULATOR

IDEA

I want to build my own CPU emulator for either a self built or Chip-8 architecture. Im very unsure which direction i want to go right now but i find the idea really interesting which is why i just started doing it. The project will (probably) be written fully in C and i hope that it will be able to run real programs. I hope the project will give me a better insight into how cpus and computers work in general

CURRENT FEATURES

Currently the CPU can add values to and jump between register and finally terminate itself. The values that are added/subtracted are set before compilation.

0
0
33
Ship Pending review

A fetching program displaying live information written in C!

What is in it?

A live system-info fetch tool, written in C

What am I proud of?

I’m mostly proud of the general parsing framework I’ve built. I built a parsing framework that reads input line by line (buffer block by buffer block) and extracts information from each line. Even though there is no singular parse() function almost every function that utilizes the parsing framework is very similar (even though slight modifications had to be done because almost no two files are structured the same way)

How is it built?

It’s built in C using ncurses, split across 12 source files, each handling one general task. There is a pre-compiled build that was built with GitHub workflows. The binary can be directly downloaded from the repo’s release page and can be used on (most) glibc-based Linux distros (build is compiled for Ubuntu and ncurses has to be installed on your system).

What I learned

I think the thing I learned the most is how to properly parse files and how to extract information from them. I have never done anything like that before (it’s my second real project ever) and it was really interesting to learn. I also learned how to handle with virtual files from the /proc/ directory (e.g. /proc/cpuinfo, /proc/meminfo etc.) which was rather hard because they don’t exist on your drive.

Known limitations / plans for the future

The project should only work on glibc Linux distros (as mentioned). There are no known bugs currently and according to Valgrind the program is memory-safe. Bugs can still occur and not every system (e.g. dual-socket systems) will work correctly. The project should still work on most systems it’s tested on

Closing word

This project was a lot of fun and genuinely interesting for me. It was the first practical step toward the kind of work I want to do with coding. It was really interesting to see parts of my OS I hadn’t touched before, and it was a great learning experience.

  • 6 devlogs
  • 20h
Try project → See source code →
Open comments for this post

2h 11m 59s logged

LOG 6: LAST LOG BEFORE SHIP, LAST LOG FOR STARDANCE SADLY. UPTIME, IP AND SHELL FETCH

FEATURES

UPTIME FETCH

Reads /proc/uptime and parses it. Because the output is in second it gets parsed to seconds

IP FETCH

Uses iffaddrs and looks in the linked list of the function for the first non loopback ip address (IPv4)

SHELL FETCH

I usesd getenv(“SHELL”) to get the path of the shell, which i afterwards parsed using strrchr to find the exact name of the shell.

MISC

Added a license (MIT and a notice to Fastfetch as some ASCII’s are from the Fastfetch repo), added a README and a workflow.yml (for automated builds).

NOTE

Sadly the last devlog isn’t that long (maybe thats a good thing tho idk).

0
0
13
Open comments for this post

2h 34m 26s logged

LOG 5: LOCALE FETCH, NEW ASCISS, BUG FIXES

FEATURES

LOCALE FETCH

The fetching program now reads your main locale from /etc/locale.conf (the LANG= locale) and prints it out.

NEW ASCIIS

I added asciis for Ubuntu, Gentoo and a special ascii for distros that currently arent supported. I drew the Ubuntu ascii myself and got the tux and gentoo logo from the fastfetch repo.

BUG FIXES

LOGIC ERRORS/TYPOS

There were a few logic errors that resulted from mainly typos/unaware coding. As an example i used strlength as an index for a buffer instead of the designated buffer index variable which resulted in unexpected behavior.

MISC CHANGES

CLEAR CALL IN MAIN LOOP

Previously the loop didnt erase during iterations which COULD cause issues in the future. Because of that i added a clear call to the top of the loop. Because of that an issue appeared with cpu fetch (the output was flickering). The fix was to reset the fd during every iteration of the major loop in the function.

0
0
24
Open comments for this post

3h 9m 22s logged

LOG 4: DISK FETCH, HOST/USERNAME FETCH, KERNEL FETCH, MEMINFO REWORK

FEATURES

DISK FETCH

The program now displays your current disk usage and your max disk space. This is done by using the sys/statvfs library and getting f_blocks (total size of your drive in blocks) and f_bfree (free space in blocks) and formatting it into GiB.

HOST/USERNAME FETCH

At the top the program now displays the current user and the hostname of your device. The hostname is read from /etc/hostname and the username accessed by using the pwd library and setting a variable to your pwuid in which your username is stored.

KERNEL FETCH

This now displays your current linux kernel version which is read from /proc/version and then parsed and output as most of the rest of the infos of the program

FIXES/REWORKS

Previously the program spat out somewhat false/misleading stats (partially because of me naming the stats a bit inaccurately). This was as said partially because of me naming it a bit inaccurately but more importantly because the logic was a bit weird. The code of the part responsible for meminfo was different to the concept of the rest of the code and was way harder to read (for me at least) and because of that i made the code conform to the design trend of the other files and now meminfo works great

THINGS THAT NEED TO BE DONE

I still need to get better asciis that have some kind of similar size (the nixos logo is way smaller than the rest, check out the other pictures for reference) and i also need more asciis in general. Overall i think im pretty close to shipping actually

0
0
23
Open comments for this post

3h 14m 57s logged

LOG 3: DISTRO FETCH, ASCII LOGOS, CPU FETCH FIX

FEATURES

DISTRO FETCH

The program now detects what distro your using right now and gives the name and the current version back (/etc/os-releases , PRETTY_NAME). The implementation is similar to the CPU fetch but some of the parsing had to be changed

ASCII LOGOS

In addition to the name and the version of your distro the program also displays a ASCII picture of the distro. Currently Debian, Arch and NixOS are supported but i plan to add more. Issue currently is finding appropriate ASCII’s, if you know websites/apps to find ASCII’s of distros please write a comment because the ASCII’s are hard to find

BUG FIXES

CPU FETCH BUGFIX

The bug described in the last log was mainly caused by the function that is responsible to create the array of the dynamic value (ae your CPU name), was called on every iteration of the loop. The fix was to move that function(s) to the conditional at the end of every line.

0
0
40
Open comments for this post

6h 8m 5s logged

LOG 2: CPUINFO (unfinished), LIVE VALUES

CPUINFO

I am currently working on displaying the CPU info but the display is faulty and i havent found the issue yet, but i felt posting a log after 6 hours was necessary. The parsing of /proc/cpuinfo has turned out to be way harder than /proc/meminfo yet its (almost) working.

LIVE VALUES

I made the values refresh after 2 seconds to get an accurate read of the current usage. This is done by looping the meminfo function and most importantly regenerating it by using lseek to reset the index which regenerates the file.

0
0
40
Ship Pending review

A roguelike room crawler completely built in C!

What is in it?

  • Randomly generated rooms with a fog of war for you to explore
  • Three different enemy types with scaling difficulty
  • Boss fights with unique item drop
  • RPG Style fighting
  • An interactive inventory that can be used during battle
  • A battle log that tracks everything that happens in battle
  • Items, pickups and a persistent highscore

What am I proud of?

The enemy pursuit and fleeing system. It was somewhat hard to implement but I think it made the game wayyyy better than before. I’m also proud of how the state machine turned out in the end. The game has strict separations between the different game states and first handles what the player/the game did during the game loop iteration and then after that is done draws it to the screen. That state machine was very prone to bugs and I had to spend a bunch of time to fix (fallthrough bug, etc. all talked about in devlogs). But I think the result that turned out at the end was great and I am very content with it

How is it built?

As said its completely built in C using ncurses as its graphics library using 12 source files (currently) with each one having a specific task only it does. The build is released using GitHub workflows and the binary can easily be downloaded and used on (almost) all glibc linux distros (the project was compiled for Ubuntu and you will have to install ncurses though)

What I learned

The game was actually my first real coding project ever apart from a few simple websites so I learned a bunch. I learned how to separate state transitions, I learned the importance of good and bad switch statements, bounds checking (really rough path) and I think most importantly: The power of code separation and making every file do its designated task. I often caught myself picking the easy and sloppy path and then fixing it properly and in retrospect helped with preventing a bunch of bugs

Known limitations / plans for the future

It’s my first project, so there are likely still issues I haven’t found. Even though I tried to find everything (a.e. using Valgrind told me there are no memory blocks definitely lost) there are still potentially memory safety issues or potential segfaults. It’s possible some edge cases might have slipped through. I’ve tested the project thoroughly and haven’t found any crashes since the last few debugging sessions but I cannot safely say it’s perfect.

I think if I will find the time I will maybe add some new features like new special item related enemies or player status effects though I cannot safely say if i can

Closing word

I think building a game for my first real project was the right decision for me because I really had a bunch of fun building this project. I currently have some ideas for unrelated new projects (one is up on my profile check it out (; ) and I think this project was a really good pathway into coding for me. Check the GitHub and the demo video out and I hope you like the project

  • 26 devlogs
  • 58h
Try project → See source code →
Open comments for this post

3h 6m 33s logged

LOG 26: FINAL DEVLOG MAINLY BUG FIXES AND SOME MINOR CHANGES

CHANGES

Enemies previously scaled to strongly and beat you too hard after the boss fight. Also because it was hard to scale the opponents down i decided to make the hp of everyone higher (everything got stronger in theory, player has 100 starting hp, does 20 damage etc.)

LATE ADDITIONS

LICENSE

I licensed the project under the MIT licesne because it seemed fitting

BUILD FILE

I added a build file for the repo so i could upload a release binary (ncurses is required tho)

BUG FIXES

HIGHSCORE BUG

There was a bug with the highscore not being displayed when there was no highscore.txt file. I needed to change the handling of the fact that the open function returned NULL, because NULL either meant, no file was there or no file could be found which resulted in no file being created because the function exited when the open function returned NULL, the fix was pretty simple overall tho (just adding an extra if conditional to check)

FULL INVENTORY BUG

Previously when having a full inventory, you couldnt pick up new items, issue was when using items that state didnt reset so one full inventory meant no items anymore :( . The fix was just to reset the state after using items

BOSS ITEM INVENTORY BUG

I forgot to make the boss item return the correct state which resulted in the item sometimes not being put in the inventory. The fix was just to add return ENTER_LEGAL to the boss items if statement

SET ROOM ISSUE

Because of random rooms sometimes boss room dimensions where bigger than current room which resulted in bugs (see previous devlogs). My previous fix worked in theory but had more affinity for potential bugs so i changed the set room function from two static values to two values that get passed into the function

0
0
18
Open comments for this post

2h 12m 1s logged

LOG 1: MYFETCH, MY OWN CUSTOM FETCHING PROGRAM

IDEA

I dont know why but fastfetch is pretty slow on my pc and i dont like htop/btop so my idea (currently) is to build a mix of a fetching program and a task manager like htop/btop

CURRENT FEATURES

Currently the program displays state of memory/swap even though the dynamic ram stats are a little off right now which i will fix in the next devlogs. Currently the ram info is read from /proc/meminfo using unformatted read/write functions for speed/efficiency

0
0
22
Open comments for this post

5h 0m 51s logged

LOG 25: FLEEING ENEMIES (CONTAINS MANY CHANGES), BOSS ITEM REFACTOR

FLEEING ENEMIES

Enemies (except the boss) now have the ability to run away if the enemy would get killed by the next attack. The chance for this to happen is 10% and when they run away, they gain 1 HP per step they take and return to chasing the enemy if their hp is back at half of their max HP.

FLEEING REWORK

Before adding this feature, fleeing was the same practically as winning (the return type of the fight was STATE_VICTORY), i changed that to the proper STATE _FLED. Also before when fleeing, if you fled and another enemy of another type collided with you, he had normal stats but the enemy before that also got his stats reset. The same went for enemies of the same type. When fleeing from enemy A from type A and then colliding with enemy B from type A, he would have the stats of enemy A. The fix for both was to make a 2D Array of all enemies and their types, so each individual enemy stores its stats, not the battle function.

PLAYER POSITION STRUCT

Previously the player had ~ 8 different position variables, which was pretty clunky if i wanted to transport the player position to another function. Because of that i put all player positions into a singular struct, so i could pass all the player positions at once if i needed to.

ENEMY PURSUIT FUNCTION REWORK

Because enemies have to run away instead of chasing i had to rework the pursuit function a bit so it could also work in a reverse way. I had to make the function branch between the two states which took a bit more work than originally anticipated because i had a bunch of wrong ideas for how the function should work. Overall the function implementation was essentially to just use the inverse vector of the normal vector for the direction function

BOSS ITEM FUNCTION/ITEM FUNCTION REFACTOR

Because previously the boss item detection function and the item detection were separate the code didnt feel clean at all (felt like a lazy implementation for me), so i made the item function work with the boss item which makes the item function overall more open for new item types (if i will add any more)

0
0
13
Open comments for this post

4h 13m 51s logged

LOG 24: BOSS ITEM DROP, CONTROLS SCREEN, NEW IN-GAME BANNER, ITEM TO INVENTORY REFACTOR, BUG FIXES

FEATURES

BOSS ITEM DROP

I added an item that only the boss drops, when killed. Its ability is to make the enemy unable to attack for one turn. You will always get it when defeating the boss and has the ‘?’ glyph compare to regular items (‘+’). Its also the only item that can always be picked up (with normal items, if your inventory is full you cannot pick them up, with the boss item your first slot gets overwritten).

CONTROLS SCREEN

I added a basic controls screen so people that try the game out (now or when it ships), know what to do when playing. Currently most things are really straightforward but i added it just in case. The most important aspect will probably how to end the game because thats the most unintuitive one (even though i hope anyone testing the game doesnt want to quit it)

ITEM TO INVENTORY REFACTOR

I thought that the previous state of my item to inventory were pretty lazy so i changed the logic up a bit. Previously when picking up items the items would go into the spot after the last item that was picked up and when the inventory ran full the first item was swappped with the newly picked up item. I didnt like that looking back and because of that the logic now scans through the inventory until it finds an empty spot and puts the item in that empty slot. If the inventory is full no item can be picked up (except the boss item) and the player gets a message on their screen. They can then leave the item screen using ESC and the item is not removed and can be picked up later if you somehow make space in your inventory

NEW IN-GAME BANNER

Also pretty straightforward, i added a banner so the menu looks a little bit prettier :)

BUG FIXES

BOSS ROOM BUG

Because of map and gamestates and me forgetting to implement a feature in the door collision checks, there was a bug when defeating the boss (the map stayed as it was, but had the usual visible map ‘#’ everywhere you hadnt already explored (you cant really explore much so there where many ‘#’ ’s around the map which was really ugly. The fix was to move a mapstate change from the function that is responsible for handling victory to the function handling doors

BOSS BUG

There was a bug after defeating the boss which resulted from the previous bug and its fix. Because i forgot an additional check in my door function when defeating the boss the boss would spawn again and overwrite your boss item. The boss also chased you (which normally doesnt happen) and you couldnt leave the room. The fix was just to add another condition to the if statement in the door function responsible for the boss room

ENEMY REMOVAL BUG

For some reason (i dont know how i made the bug happen), when defeating enemies the visible map lagged behind the normal map which resulted in defeated enemies appearing to still exist on the map for one iteration of the loop (pressing any button made them vanish). The fix was to add a call to the visible_map_init function after defeating enemies

0
0
5
Open comments for this post

2h 16m logged

LOG 23: BATTLE LOG FOR ITEMS, BUG FIXES, BUG FIXES, BUG FIXES, BUG FIXES

FEATURE

BATTLE LOG FOR ITEMS

The previous battle log only logged attacks and the damage dealt, now the log also tracks if items are used or items deal damage

BUG FIXES

SEGFAULT

There was a segfault when trying to render the bottom of deeper rooms because the render guard had a major fault (only disjunctions no conjunctions). Because of that the game tried to reach spaces of the visible_map array out of reach of the array which resulted in a segfault when trying to go into spaces out of reach of the array. The fix was changing the guard from if ((player_y + y) < MAX_HEIGHT || (player_x + x) < MAX_WIDTH || (player_y + y ) >= 0 || (player_x + x >= 0)) to if ((player_y + y) < MAX_HEIGHT && (player_x + x) < MAX_WIDTH && (player_y + y ) >= 0 && (player_x + x >= 0)) which fixed the issue

BATTLE LOG NULL TERMINATOR FIX

There was a bug with the battle log, where ^ were printed (NUL ascii in ncurses) because the battle log printed out every part of the string character by character (including the \0 terminator). The fix was to just not print out the \0 terminator to the screen

BATTLE SELECTION BUG

There was a bug with conflicting selection variables (multiple variables where named selection which resulted in wrong selections being displayed). The fix was to give every function their own selection variable which fixed the issue

VISIBLE MAP GLITCH

Because the visible map only updated itself in the perimeter you are standing in if you moved fast enough some characters lagged behind and made it look like there were way more enemies than there actually were. The fix was to update not only the perimeter on every movement but also update everything that had already been explored

1
0
131
Open comments for this post

4h 2m 42s logged

LOG 22: POISON ITEM, BATTLE LOG, MAIN LOOP AND ITEM SELECTION REWORK

POISON ITEM

A new item that does 3 tick damage every enemy turn, for 2 turns. Its the rarest item in the game as of right now and was somewhat complex to add (because of the tick damage and tracking how many turns have passed)

BATTLE LOG

A log that tracks the last two actions that have happened in the game. It currently only tracks damage and attacks but will track item usage and more detailed information in the future. It was a real headache to implement because i had contradictory logic between the log and my main loop and i had to reimplement it multiple times. But went well overall :)

REWORKS

MAIN LOOP REWORK

I reworked the main loop a bit because even though it worked well in theory it was not really optimized and it was prone to bugs in the future which is why i felt like redoing it a bit. Now instead of every function handling their own init, every changing gamestate instantly also inits the state it was changed to. Because of this there are less possible bugs and its overall easier to do for future gamestates

ITEM PICKUP REWORK

I noticed that the logic for my items wasn’t really perfect and seemed unoptimized which is why i felt like changing it a bit. Because when picking up items there are only two possible things to do (which both result in the same exit scenario) i swapped my if/else if logic for a switch statement which made the code shorter, and more optimal

0
0
25
Open comments for this post

3h 9m 46s logged

LOG 21: FOG OF WAR, HOMING ENEMIES, BATTLE LOGIC OVERALL AND BUG FIXES

FEATURES

HOMING ENEMIES

The enemies now home on you with every step you take, meaning you actually have to think about where you will go or the enemies will catch up to you. This was implemented by adding a sign function that decide whether the enemy should move +1 or -1 and then moving the enemy by that value. There were some bugs regarding enemies in previous rooms which got fixed by resetting the whole array during map init

FOG OF WAR

I added a fog of war feature that obstructs everything in the map you
haven’t explored yet. This also pairs very well with the homing enemies
feature. You have to go around the map to look out for items and enemies
which now also walk towards you, so every step matters now

BATTLE LOGIC OVERHAUL

After revisiting most of my code for commenting i realized how terrible most of my battle logic was so i made it a bit more efficient and most importantly more readable. Overall i realized how great switch statements are in the last few logs

BUG FIXES

DOOR BUG

There was a bug with the map that was somewhat useful when testing but still was a bug. The issue was that if you tried to step into the door the game let you step onto that char. The issue was that i forgot to make the game think that the door (when closed) should behave exactly like a wall. So the fix was just to add the door char to the wall collision check function

0
0
20
Loading more…

Followers

Loading…