GithubHelp home page GithubHelp logo

xoinvader's Introduction

Anurag's GitHub stats

Top Langs

xoinvader's People

Contributors

alex-eg avatar pkulev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

alex-eg

xoinvader's Issues

Scoreboard

  • Add simple scoreboard manpulating routines, add entry, get all entries, get max, get min.
  • Use simple file format, for example CSV.
  • Provide unittests for the new module.

Replace ncurces

There is need to replace ugly ncurces code by pygame or pyglet (that implemented at top of pygame), because this is more comfortable and contollable way. The best variant is move ncurces dependent code to separated module or driver (another issue).

Implement enemy waves

This component should be a thin wrapper around enemy ships list with attached animations.
It should call InGame state's add_object methods at appropriate times and add enemies with appropriate animations.

Implement simple object destruction

Abstract

Enemies and player must process situation with hp <= 0. At now simple deletion of object or showing Game Over is enough.

Design

  • State handles adding Renderable objects, it should handle and object deletion too.
  • GameObjects must register collisions.
  • GameObjects must handle collision events.

Implementation details

  • ✔️ Provide some sort of object removal chain that starts from InGameState.remove method. ✔️ (#60)
  • ✔️ Provide __del__ for game objects to clean colliders, or reengeneer CollisionManager<->Collider communication solution. ✔️ CollisionManager<->Collider reimplemented.
  • ✔️ Provide code for handling hp <= 0 situations. ✔️

Add pick-ups

Crates with ammo and bonuses.

  • detect collision of actor and pick-up
  • do something

Blocked by: #19

Add poetry support

Poetry and pyproject.toml are good things, let's use them.
Withing this issue of later we can get rid of setup.py, requirements.txt, dev-requrements.txt and MANIFEST.in replacing it with just one tiny boi pyproject.toml.

  • Add pyproject.toml with poetry settings.
  • Use poetry in makefile to install, develop, run tests and so on instead of using virtualenv directly.
  • Update .travis.yml to install poetry before all the things.

Traceback when closing window by WM.

Traceback (most recent call last):
File "game.py", line 82, in
main()
File "game.py", line 78, in main
return game.loop()
File "/home/pkulev/proj/xoinvader/xoinvader/application.py", line 154, in loop
self._state.events()
File "/home/pkulev/proj/xoinvader/xoinvader/teststate.py", line 63, in events
self._events.handle()
File "/home/pkulev/proj/xoinvader/xoinvader/teststate.py", line 43, in handle
self._owner.stop()
AttributeError: 'TestState' object has no attribute 'stop'

Implement scrollable background

Background is the battlefiled, on which the action is taking place.

It will scroll from top to bottom with some speed, that may vary.
Background may consist of several looping chunks, to reduce efforts of creating really long scrolls, and also to adapt to varying battle times (e.g. boss fights).

It can be loaded from file or it chunks may be generated proceudrally.
Mechanism to loop through chunks and to smoothly traverse from one chunk another must be implemented.

Background has the lowest Z-level, everything should be drawn on top of it.

Background should have a mechanism to change its speed of top-down-scrolling.

Real-time bound update period checks in `animation.py`

And maybe in other places too.
Measuring real time in things like animation or status update can cause problems, since it's a major side effect, which we can't turn off.
So we can't implement things like pause, because we can't stop global timer.
Also we can't change animation speed just by altering timer threshold.

Current alternative is presented in the background module, which counts number of times update function was called. This is stub implementation, however.

We should really think about how to decouple Timer and real time measuring.
However, real time measurements of course should be resent somewhere, but ideally there should be only one place, both logically and in sense of source code, where this happens.

Resource management

Alpha milestone mentions following things:

  • levels
  • weapons
  • player craft
  • enemy craft[s?]
  • enemy types
  • enemy waves
  • behavioural patterns -- as I understand, it's movement and attack patterns, which are pre-defined and bound to each wave
  • boss
  • [optional] pick-ups
  • sounds
  • music

While not all of them have to have an editor, we must decide on how to create, use and modify all of them, in terms of in-game engine entities.

Background: shrink background surface

Abstract

Background tries to render on border (I've learned it from renderer logs).
This is not quite good because:

  • Border is for GUI only, rendering other things on it breaks look.
  • Renderer doesn't render Backgound on border, but sends remove_obsolete signal almost every frame.

Implementation

Find place where Surface sends to renderer and don't use (x, 0) and (x, Settings.layout.border.y) coordinates.

Custom font setting

We live in the terminal, and thus we may run console commands and check env and whatnot.
Thus we (probably) can install font that supports unicode and even colorful emojis.

It might be quite funny.

Also we may even launch a separate terminal of our choise and provide it with all necessary fonts.

 ∧_∧  / ̄ ̄ ̄ ̄ ̄
 ( ´∀`)< オマエモナー
 (     )  \_____
 │ │ │
 (__)___)

Implement file format for text images

Abstract

We need file format to keep 3 things together:

  • text image of object (now hardcoded in class definitions in form of lists passed to Surface constructor)
  • layer of same size with color codes instead of image characters (now this feature barely usable via style parameter of Surface)
  • additional layer with attributes like bold, blink, reverse.

Application itself must register colors and attributes it uses or just use defaults.

Example

[meta]
name = "kekstrel"

[layers]
image = """
  O  
<=H=>
 * * 
"""

# w is white
# b is blue
color = """
  w  
wwwww
 b b 
"""

# n is normal
# B is bold
attr = """
  n  
nnnnn
 B B 
"""

Implementation

Add classmethod Surface.from_file(). Replace hardcoded images with files, set path to them in corresponding configs.

Animation

Abstract

Implement mechanism for creating declarative animations.
Keep in mind further implementing of animation editor.

Implementation notes

  • Animation is component, that can be dinamically added to game object.
  • Keyframe-based animation uses {local time -> attribute value} mapping and interpolation to calculate values between known time borders.
  • Game objects has better jobs than managing thier list of animation. I suppose AnimationManager can do the things. Game object now can have field with animation manager, and can add one's update to it's update function.

Menu system reengineering

Menu was created couple years ago, and now we need to improve it to work with menu hierarchies using that multimedia framework activities we have. This also needed for using scoreboard.

  • [Some]MenuState is typical xoinvader.state.State, that holds renderable objects and so on.
  • Menu is a tree structure of menus.
  • [Some]MenuState has current Menu property and routines to change current menu.
  • Switching current Menu turnes off visibility of menu entry widgets or modifies _object list to replace widgets by other menu's entries.

Submenus

Menu structure is a tree, each it's node can provide command override (e.g. as classfield).

Render: don't render behind actual terminal size

Split checks in render into 2:

  • Check if we're going to render behind terminal, if so then skip.
  • Check if we're going to render on border (strict check). This is needed for UI.

This will prevent errors while resizing terminal.

Python 2.x support

I've made several changes towards cross-python compatibility, but I've stuck with unicode passing to curses add* functions.

Need to fix this.

Implement proper logging

Now we have awful zaichatkie of logging.
Read about logging module and do it properly, with configuring root logger and getting it when needed as well as subsystem loggers.

Input abstraction

We can provide some sort of input abstraction and reuse it for both backends.
Instead of getting raw key and making all math in game objects' update methods we can use something like Input.axis(...).

Game doesn't run due to tornado 5 API changes

PeriodicalCallback.init now doesn't expect ioloop as parameter.
Also briefly scrolling of ioloop module I saw that some things I use in application package are deprecated by v5. Upgrading tornado will be in separate issue, here we can just lock tornado version.

Improve collision detection

Current implementation is naïve -- it just checks all possible collisions between all possible objects, traversing the list of registered collision combinations and then objects of corresponding types.

This is complex in a cyclomatic way. Thus it needs to be improved. The idea is to make use of some logarithmic data structure, like BSP-tree or quadtree to divide objects and to decrease number of unnecessary checks, and to get rid of that horrible deep loop nesting.

Split Weapon to Weapon and Charge

Abstract

Weapon shells (bullets, charges, beams) must be separate GameObject with separate _image property. Weapon can have own _image for example.

Implementataion

  • Make new charge.py module
  • implement charge hierarchy and mechanics
  • move out charge-specific code from Weapon into charge

Brand new object system

THIS IS DRAFT

Abstract

This time not came yet, but some changes we need to do in order to unblock further development.
We need to design and implement as simple as possible object system that will fit to our needs for this time.
We have ships and backgrounds that have Surface to render. We have projectiles that looks like not good designed lists of coordinates...

Design

GameObject and State

  • GameObject is recursive data structure that have position in world coordinates if it is not part of another object, otherwise it has local coordinates as offset to parent object.
  • Each GameObject can hold subobjects of type GameObject with own colliders, animations, sprites.
  • State as implemented now is a scene, that holds game objects and does all interations with them in loop when this state is active.
  • State can hold many instances of GameObject.

Appllication and States

  • Application holds one or more States and executes current state.
  • Only one State can be used in one time.
  • Apllication calls in the IOLoop 3 methods of current State object: events(), update(dt), and render().

Event-based messaging

  • Every State has it's own message queue to provide messaging between objects and maybe even whole engine subsystems.
  • (Optional) Application can have dedicated queue for something.
  • GameObject can put event into queue via it's State.
  • EventHandler of State pops all events from queue and process them on events stage of the State.

Game-specific implementation examples

Ship

class PlayerShip(Renderable):
    def __init__(self, ...):
         self.add(WeaponSlot(transform, ...))  # transform is offset
         self.add(WeaponSlot(transform. ...))  # that applied to PlayerShip's transform
         self.add(LeftEngine(transform, ...))  # maybe some form of declarative definition

class InGameState(State):
    def __init__(self, owner):
        self._actor = PlayerShip(transform, ... )
        self.add(self._actor)  # will be rendered and updated

class InGameEventHandler(Handler):
     def handle(self):
          # after input
          for event in self.owner.get_events():
              if event.recepient:
                  self.dispatch(event)
              # some other things
              

Weapon

class Weapon(Renderable):
    def update(self):
        if self._fire:
            self.add(Projectile(self))
        ...

Collision detection

class RocketProjectile(...):
    def on_trigger_enter(collider):
        if self.side != collider.game_object.side and collider.game_object.side != "obstacles":
            collider.game_object.apply_damage(self)
            ...

Simplify config usage

Now configs are read only, no need to create machinery to mantain wierd cases.
Now config (Settings) creates on import time, with some singletones raises problem of depending on import order.

Solution:

  • make separate module common
  • move all config related code from common.py to config.py
  • create config not on reading time, use class or function
  • look at singletones, maybe no need to use this antipattern

Add animation interpolation

Abstract

We have animations, we need to interpolate values. There are two common methods: linear equation and curve-based interpolation. As simpler and more appropriate for ASCII GAME ENGINE we used to implement linear interpolation.

Design

Empirical formula is:
interpolated = value1 + (value2 - value1) / (time2 - time1) * (current_time - time1)
Where:

  • (time1, value1) and (time2, value2) are keyframes
  • current_time is current local time of animation (between two bounding keyframes)

Implementation details

  • For now it's enough to implement interpolation for next types

    • int, float
    • utils.Point
  • Split Animation.update method to two for interpolated and fixed (discrete) animation.
    This needed due to different approaches to animation keyframe switching and will too
    complicate code to keep single codepass.

Implement logging to file

#While working on #19, I found myself in a dire need of logging facility.
I was debugging filter/list issue, and ncurses are not very friendly towards output that bypasses their own methods.

So I naturally did something like this:

with open("debug.log", "w") as f:
    ...
    print("List:", l, file=f)
    ...
    print("More info", info, file=f)

And so on. It was quite useful, but it's tedious to write this all by hand, and even more tedious to clean it all up. So I thought that we might benefit from having our own logging facility.
In fact, I'm surprised that we don't have one yet.

UPD. It turned out we have logging after all. It's in utils.py. Whatever, then we need to have a wiki article on it.

Sorting layers

Idea

Good combines with implementing some sort of projects.

  • Project is configuration file that contains user overrides for engine settings.
  • This file can be further created with an editor.
  • Example is sorting layers:
Settings.project.sorting_layers = [
    "GUI",
    "Player",
    "Enemies",
    "Pick-ups",
    "Background"
]

# Somewhere in game classes
class Background(Renderable):
    sorting_layer = "Background"
    ...

"default" is initial value for every untagged object.

This is unity-like alternative to Renderable.render_priority with meaningfulness instead of strange integers.

Implementation

  • add initial project config file with declarations for game and applying mechanism for it
  • Use sorting layers instead of render_priority
  • Implement sorting by defined priorities

Maybe a little difficult to implement sorting, need some kind of prototyping.

@taptap, let's discuss it.

Collision detection

  • add to entities field collider with some type and parameters
  • add common mechanism for checking collisions
  • provide set of colliders for different shapes (Sphere, Box, Custom shape)
class ERocketLauncher(Weapon):
    super(ERocketLauncher, self).__init__(**CONFIG[self.type])
    self._collider = SphereCollider(pos=Vec3(0, 0), radius=1)
    ...
  • insert somewhere to right place collision detection routine for every appropriate object (maybe in event handlers)

* add code for actions on collision

Further collision detection code will be moved into engine and colliders will turn into components for lightweight entities.

Collision detection tightly coupled with event system and object system.

Debugging console

Debugging console or some kind of tool for interacting with engine and showing current state.

Convert background format into text texture compliant format

Abstract

Now background has it's own format, but with texture we can unify it. It will be needed later for level description file format and also we will be able paint background with different colors.

Maybe we can even use chunks from several background files at once.

Example

[meta]
name = "small town"

[chunk.bridge]
image = """
  \      /
   |    |
   |    | 
   |    |
  /      \
"""

color = """

"""

attrs = """

"""

[chunk.something]
image = """
  ^^^^^^ ^^^^^^ ^^^^^^
 00 000 000 000 00 00 0
"""

Implementation

Replace old parser or add new one.

ci: add multiple python version testing

Add travis build for next versions:

  • 2.7
  • 3.4
  • 3.5
  • 3.6
  • 3.7 -- Fix raising StopIteration in scoreboard.items(), it will not be suppressed since 3.7.
  • 3.8 -- Issues with installing pygame.

Segmentation fault with ncurses-6

ncurses-5.9 works well, but segfaults with version 6.
Looks like all broken here: 8b1d6c2.
Previous commit works well on python2.7.11 and python3.5, but this only with python2.7.11.

Traceback: ... > curses.cbreak()

2016-10-10-180119_781x593_scrot
2016-10-10-180133_966x757_scrot
2016-10-10-192002_950x661_scrot

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.