The Code Structure Of Tweet_Dungeon (πΆ Tweet_Dungeon dev log #2 π)
π§¬π§¬ The Code Structure Of Tweet_Dungeon
Making a game can be a hefty ordeal. Various API's, complex algorithms, and a lot of code go into making Tweet_Dungeon what it is. Today, we're going to take a nerdy look into how I manage the game logic behind the scenes, and tips I'm using to stay sane working in this codebase.
ππ Folder Structure
In an effort to stay sane, I decided to split up the code into various, isolated parts.
The CORE
folder contains the core mechanics of Tweet_Dungeon (dungeon generation, player controller, world config, enemy behavior, etc.). This code won't actually display anything onto your screen, and won't exactly work on its own.
Then, we have the... Well, everything else. The beauty of isolating the CORE
game code, is that you can then basically "drag + drop" it into your own game version.
For instance: There's currently a rough prototype of Tweet_Dungeon available here. This can be considered a game "version". Any changes I make to the core Tweet_Dungeon logic can be automatically pulled into the prototype to keep it updated.
If you're aware of the concept of the Git File System, then you can think of the core Tweet_Dungeon logic being a repo (that's because it actually is...) that you can fork, modify, clone, and include in your own variant of Tweet_Dungeon.
Speaking about Git...
π»π» Open-Source, Of Course!
Tweet_Dungeon will, in fact, be open-sourced upon release. There are currently 3 GitHub repo's that we use:
Tweet_Dungeon-CORE
: the main code & game logic that is required to run Tweet_DungeonTweet_Dungeon-TWITTER
: the specific Twitter bot code that allows play through TwitterTweet_Dungeon-CAVERN-KIT
: a set of pre-made dungeon "rooms", called caverns, allowing you to quickly bootstrap your own version of Tweet_Dungeon
In addition to these main game repo's, there's also a handful of tools that I've made to help with the development of Tweet_Dungeon, and I plan on open-sourcing those in the future, after the game launch, as well :^)
π οΈπ οΈ How Do You Work With It?
Actually, it's a rather simple method! First, you'd clone the CORE
game logic into your version that you're working on, and then you'll need to import the objects that we export in each script.
import WORLD from '@/core/world.js'
import RENDERER from '@/core/renderer.js'
import PLAYER from '@/core/player.js'
import ENEMIES from '@/core/enemies.js'
When you're game is set-up and ready to run, call the WORLD.init()
function, and pass it the reference to RENDERER, PLAYER, and ENEMIES. Remember, call this method when booting up your game (for instance, if using VueJS, put this into the mounted()
life-cycle hook):
mounted() {
WORLD.init(RENDERER, PLAYER, ENEMIES) // initializes the game world
WORLD.generate_random_dungeon() // generates a random dungeon
}
This will take care of initializing the game code, and you can then start playing your own version of Tweet_Dungeon! Additionally, this makes it easy to swap out any code that we provide, with your own custom code, giving you full control & customization over the game. Everyone gets a game!!!
We want to give indie-game-devs a jump start with making their own clones of Tweet_Dungeon. We have big plans for this game. First? Twitter. Then? THE WORLD!
(no, but seriously, we have tons of stuff planned for the future. various game versions, wonderful new worlds, many different mediums, and much much more!)
βΉοΈ Nitty-Gritty-Code-Details
Here's some Tweet_Dungeon development fun-facts to end on:
- Programming Language: JavaScript, my favorite language
- Emoji Library: Twemoji (twemoji.twitter.com)
- Frontend Framework: VUEJS (vuejs.org)
- Current CORE Game Code Size: ~50kb, so far ;^)
What Is Tweet_Dungeon? πΆπ
Tweet_Dungeon is a Twitter-based dungeon-crawling roguelike game, where the entire game (moves, attacking, looting, exploring, etc.) takes places entirely on Twitter. Players vote on what the little adventurer will do using Twitter polls. Turns are 20 minutes long, and updates constantly all day long.
Follow along with my progress where each day I'll post a short dev log showcasing the latest stages of the gameplay. Will I be able to make the deadline of Thanksgiving (November 28th, 2019)? Only the game-dev-gods can tell...
T-6 DAYS...
T-6 DAYS...
@tipu curate 2
@untersatz curate 2
Upvoted π (Mana: 0/10 - need recharge?)
The @untersatz witness and manual curation is under the guidance of @contrabourdon and @organduo.
Thanks! I really appreciate that :^)
Congratulations @stuffbyspencer! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
This post earned a total payout of 1.027$ and 0.772$ worth of author reward which was liquified using @likwid. To learn more.