Giter VIP home page Giter VIP logo

orb's Introduction

Orb

Allright, so 2 days for such a project is a pretty tough timeframe. Still pretty fun project to deal with.

So, I decided to not use any third party lib/code, only unity stuff, so the most confusing part may be the DI, because I wrote some simple di container (SimpleDi class, IResolver, IBinder interfaces) and the bindings/bootstrapping is in DiContainer.cs.

The game is divided into assemblies: Core and Physics contains the game mechanics, Di, Di.Simple and DiContext are all part of DI implementation, View is for game mechanics entities that exist in scenes and are dependent on Core, Ui is all ui-stuff, Meta contains parts of game that wraps core gameplay into metagame with main menu/restarts/loading scenes/preparign DI etc, and Save which is pretty straitforward.

Basically the main part of the game is in Game class, which got a little messy by the end, you may start looking from there. There are 2 weapons, single shot and multi shot, assigned randomly at start. Planets can be manipulated from scene, they have mass and hp. Human and ai players are assigned randomly as well. Ai is stupid, it just shoots randomly, but in this game it's still pretty effective strategy.

All bullets and planets (and star if you let it) obey gravity, which is calculated by newton intergation in Solver.cs. Newton behaves very funny at small distances/large forces, so I'd like to use rk4, but that's really out of scope. You may try putting another star near the existing one to see everything go crazy. The idea of Solver was to implement a kind of ecs approach, which it isn't, but still showing nice performance considering the amount of bodies in simulation. As it is put out in different assembly it would be pretty straitforward to move it more towards unity ecs, or doing the pattern manually.

Saves are not saving everything, but it is there to show the point, how it would have been done with this architecture. No game part, except for Orb.Save assembly knows anything about serialization/jsons/whatever. This is not how I'd have done saves in a larger project, because it has no versioning, conversion between versions, error handling, but it's good enough to show the intent here.

Weapons are added by one per planet, which is easy to change, and are created by factory which scopes all appdomain. This is pretty dirty, and the ugly refection code should be put away somewhere else. Still this way you are not limited by the damage/acceleration/reload constrains and can create any kind of weapon without messing with already existing code. Pretty much the same goes for planets and bullets, hence the factories.

orb's People

Contributors

gisachenko avatar l4fter avatar

Watchers

 avatar

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.