Month: November 2014

Project: “Space Trader” (Python)

Inspired by the transport tycoon type game, the complete specifics are still being debated, but effectively I’m aiming for managing a space company, with the possibility to focus on different avenues.

Pure trader – Move goods around, buy low, sell high. Don’t forget to factor in transport costs!

Research – fund new research into, mining, manufacturing and design. Then sell these technologies to other companies for royalties and/or lump sums!

Manufacturing – Take raw resources and manufacture them into different products, these products need researching so either research them yourself or buy from another company!

Reconnaissance – explore the unknown, send scout ships to map an area, or send the prospectors to find out what resources lie hidden on the planets. On behalf of your company or others; For a price!

Current aims:

  • Generate a Section of a galaxy divided into sectors, each sector is then populated with solar systems and other objects.
  • Procedurally craft a small section of a galaxy, down to the resources on a planet (albeit a little abstracted).
  • Create an economic simulation that shifts causing supply and demand to change. The effects of competing companies.

I have mainly been working on the rendering and organisation of the differing levels, so far I have achieved:

  • Animated Sprites, with customisable “tick” rate.
  • Ability to pan.
  • Parallax sprites – that when panning move in an offset fashion to normal sprites.
  • Selection of objects with mouse.
  • Randomly generated “solar systems” and “asteroid fields”, not procedurally done yet.
  • Different levels of “view” Galaxy, Sector, Solar System and Planet(or other objects), that allow for more in depth information.

 

Some development pics
(yayy for programmer art and opengameart.org/):

Sector view, with solar systems and asteroid fields plus debug connections

Sector view, with solar systems and asteroid fields plus debug connections

debug boxes and houses as "planets" and a planet.... oh.

debug boxes and houses as “planets” and a…. planet…. oh. Planet is my art, rest was opengamart.org acquired

 

Pyglet and ecs Part 2: Flying Around

So right now we can give entities images. However, they don’t do anything on screen other than stay very still in the location we put them. To change this we need to give the entities a Physics component this will allow for the entity to update its position.


#components.py

class Physics(Component):
    def __init__(self, vx=0.0, vy=0.0, thrust=100.0, rotate_speed=100.0):
        self.vx = vx #the velocity in the x axis
        self.vy = vy #the velocity in the y axis
        self.thrust = thrust #the amount of force we can apply
        self.rotate_speed = rotate_speed #how quickly we can rotate.

We also need to build the accompanying PhysicsSystem, which will require the use of Physics component and the Transform component.


#systems.py
class PhysicsSystem(System):
    def __init__(self):
        System.__init__(self)
        self.drag = 0.4

    def update(self, dt):
        for entity, phys_comp  in self.entity_manager.pairs_for_type(Physics):
            #we need our transform component to update the position of the entity
            pos_comp= self.entity_manager.component_for_entity(entity, Transform)

            #times it by the delta time to get frame rate independent movement.
            pos_comp.x += phys_comp.vx * dt
            pos_comp.y += phys_comp.vy * dt

            #apply drag to velocity.
            phys_comp.vx -= phys_comp.vx * self.drag *dt
            phys_comp.vy -= phys_comp.vy * self.drag *dt

To get our player to start moving we need to update the entity factory create_player() method and add the system into our SystemsManager. To test the movement system is working we can give our player an initial velocity, it’s a one line addition after the other components

(more…)