Commits

Daniel Pope  committed c6a1fba Draft

New: hot air balloon

  • Participants
  • Parent commits dabcc51

Comments (0)

Files changed (11)

File korovic/components/balloons.py

 import math
 import pyglet.sprite
 
-from .base import Component
+from .base import Component, ActivateableComponent
+from .engines import OnAnimation, ActiveSound
 from .squid import Tether, Slot
 
+from ..controllers import PressController
 from ..vector import v
+from ..sound import load_sound
 
 
 class Balloon(Component):
         self.tether = None
         self.create_body()
         self.tether_to(self.squid.body) 
+        super(Balloon, self).reset()
 
     def bodies_and_shapes(self):
         bs = super(Balloon, self).bodies_and_shapes()
         if self.tether:
             self.tether.draw()
         super(Balloon, self).draw_component()
+
+
+class HotAirBalloon(ActiveSound, Balloon, OnAnimation, ActivateableComponent):
+    slot_mask = Slot.TOP
+    FUEL_CONSUMPTION = 0.1
+    MASS = 7
+    
+    temp = 0
+    MIN_LIFT = v(0, 10000)
+    MAX_LIFT = v(0, 80000)
+    started = False
+
+    sound = load_sound('data/sounds/hotairballoon.wav')
+
+    def update(self, dt):
+        ran = False
+        if self.active:
+            if self.squid.draw_fuel(self.FUEL_CONSUMPTION * dt):
+                if not self.started:
+                    self.on_start()
+                    self.started = True
+                ran = True
+                self.temp = min(1, self.temp + dt * 0.05)
+        else:
+            self.temp = self.temp * 0.9 ** dt 
+        if not ran and self.started:
+            self.on_stop()
+            self.started = False
+
+        # Not actually apply the lift
+        self.LIFT = (
+            self.temp * self.MAX_LIFT +
+            (1 - self.temp) * self.MIN_LIFT
+        )
+        super(HotAirBalloon, self).update(dt)
+
+    def is_enabled(self):
+        return self.squid.has_fuel()
+
+    def controller(self):
+        return PressController(self)

File korovic/components/base.py

     def is_active(self):
         return self.active
 
+    def on_start(self):
+        pass
+
+    def on_stop(self):
+        pass
+
     def reset(self):
         """Reset the state of the component."""
         self.active = self.initial

File korovic/components/engines.py

     OFFSET = v(0, 0)
     started = False
 
-    def on_start(self):
-        pass
-
-    def on_stop(self):
-        pass
-
     def force_angle(self):
         return self.angle
 

File korovic/data/components/hotairballoon.json

+{"points": [{"radius": 60, "name": "1", "offset": [61, 75]}, {"radius": 56, "name": "2", "offset": [62, 90]}, {"radius": 54, "name": "3", "offset": [62, 56]}], "radius": 6, "name": "sprites/hotairballoon.png", "offset": [-63, -189]}

File korovic/data/sounds/hotairballoon.wav

Binary file added.

File korovic/data/sprites/drip.png

Old
Old image
New
New image

File korovic/data/sprites/hotairballoon-on.png

Added
New image

File korovic/data/sprites/hotairballoon.png

Added
New image

File korovic/editor_hud.py

     Item('Propeller', 100, components.Propeller, 'Contact!'),
     Item('Small Fuel Tank', 40, components.SmallFuelTank, 'A little fuel goes a long way!'),
     Item('Large Fuel Tank', 75, components.LargeFuelTank, 'Is zis too much fuel for you?'),
-    Item('Balloon', 10, components.Balloon, 'Ninety-nine Luftballoons...'),
+    Item('Balloon', 35, components.Balloon, 'Ninety-nine Luftballoons...'),
     Item('Pulsejet', 150, components.PulseJet, 'Vould you like to cruise like a V-1, Susie?'),
     Item('Rotor', 500, components.Rotor, 'You are Susie, not Huey, yes?'),
     Item('Hang Glider', 100, components.HangGlider, 'And it vill keep ze sun off you!'),
     Item('Ekranoplan', 400, components.Ekranoplan, 'I stole zese from ze Russians.'),
+    Item('Hot Air Balloon', 275, components.HotAirBalloon, 'Up, up and avay!'),
 ]
 
 GREY = (90, 90, 90, 255)

File source/concepts.svg

Old
Old image
New
New image

File source/logo.svg

Old
Old image
New
New image