Virtual Electricity
Draina is all about electricity. Draina even refers to the Drain Voltage when talking about electronics in physics. Keeping our close relationship to realistic electricity in mind, it was essential to figure out the best way to implement electricity in a way that would accurately show how electrons behaved.
In a sense, electrons move quickly, and flow in one direction along a path(/wire). At first, I attempted to keep the speed of the electrons in mind, and simply produced an animation for a wire that was powered on and one that was powered off:
I didn’t have many problems with this at first, but I soon ran into a lot of issues when more complicated wiring and puzzles came into the picture. I was honestly stumped for a while because I wasn’t sure why I was having so many issues with the way the wires were working.
It was then I realized that my implementation was all wrong. Each wire belonged to a parent object class called oElectricity. All of these objects would react the same: if one instance touched another oElectricity instance, and that second instance was electrified, the first instance would then also become electrified. But this isn’t really how it works.
Because electrons flow in a current, it’s not enough to simply having two wires connected; electrons themselves need to be the center of the implementation of electricity. So I went with another approach:
Instead of a collision-based approach, I decided to create smaller objects called oCurrent, which essentially represented each electron in a current. When a switch was turned on, electrons would be produced, and while a wire was available, the electron would move along the wire. I simply readjusted each door and switch to react accordingly on contact with said electrons. While this sacrificed some of the speed at which the electrons moved in the wire animations, I didn’t have to worry about placing a wire at a specific angle where it’s animation would make sense when electrified, I simply had to give each wire an ID of with direction the current would flow using the characters L, R, U, and D for left, right, up, and down respectively.
Future implementations with more interactions with the electricity will now be a lot easier to deal with logically, as I’ll be actually working with the electrons themselves rather than the wires.
Get Draina
Draina
Puzzle/adventure game
Status | In development |
Authors | lll337, Zane Fadul |
Genre | Adventure |
Tags | GameMaker, Pixel Art, Roguelike |
More posts
- Making DrainaMay 18, 2019
- Title ScreenMay 13, 2019
Leave a comment
Log in with itch.io to leave a comment.