Browse Source

added new level and fixed wind control

master
flyingsparx 8 years ago
parent
commit
44cdd1823f
  1. 14
      cardiff_drone.py
  2. 2
      manager.py
  3. 17
      maps.json
  4. 2
      templates/level.html

14
cardiff_drone.py

@ -47,9 +47,10 @@ class Drone:
if self.fuel == 0:
self.z = 0
self.crashed = True
if type(self.map['wind']['frequency']) == 'int':
if self.moves % self.map['wind']['frequency'] == 0:
if self.map['wind']['frequency'] == 'random':
amount = int(random.random()*4)+1
if self.moves % amount == 0:
if self.map['wind']['towards'] == 'N':
self.y-=1
if self.map['wind']['towards'] == 'E':
@ -58,9 +59,8 @@ class Drone:
self.y+=1
if self.map['wind']['towards'] == 'W':
self.x-=1
elif self.map['wind']['frequency'] == 'random':
amount = int(random.random()*4)+1
if self.moves % amount == 0:
else:
if self.moves % self.map['wind']['frequency'] == 0:
if self.map['wind']['towards'] == 'N':
self.y-=1
if self.map['wind']['towards'] == 'E':
@ -69,7 +69,7 @@ class Drone:
self.y+=1
if self.map['wind']['towards'] == 'W':
self.x-=1
if self.finished == True:
self.status = "Finished"
elif self.crashed == True:

2
manager.py

@ -96,7 +96,7 @@ def run_drone(map_number):
# Main code
if __name__ == '__main__':
app.debug = True
#app.debug = True
app.maps = load_maps()
port = int(os.environ.get('PORT', 8080))
app.run(host='0.0.0.0', port=port)

17
maps.json

@ -20,7 +20,22 @@
"obstacles": [[5,9,0],[5,9,1],[5,9,2],[5,9,3],[5,9,4],[12,7,1],[12,7,2]],
"finish": [12,9,0],
"fuel": 30,
"wind": { "towards": "S", "frequency": 3},
"wind": { "towards": "S", "frequency": 40},
"start": [1,1,0,180],
"size": [20,20],
"ammo": 0,
"finish_items": [],
"items": [
],
"drone_visible": true
},
{
"name": "Windy obstacles",
"description": "Avoid the obstacles on the way to the finish point to complete the level.",
"obstacles": [[8,3,1],[8,3,2],[8,3,3],[8,3,4],[8,3,5],[8,3,6],[8,3,7],[8,3,8],[8,3,9],[8,4,1],[8,4,2],[8,4,3],[8,4,4],[8,4,5],[8,4,6],[8,4,7],[8,4,8],[8,4,9],[8,6,1],[8,6,2],[8,6,3],[8,6,4],[8,6,5],[8,6,6],[8,6,7],[8,6,8],[8,6,9],[8,7,1],[8,7,2],[8,7,3],[8,7,4],[8,7,5],[8,7,6],[8,7,7],[8,7,8],[8,7,9],[8,8,1],[8,8,2],[8,8,3],[8,8,4]],
"finish": [12,9,0],
"fuel": 30,
"wind": { "towards": "S", "frequency": 2},
"start": [1,1,0,180],
"size": [20,20],
"ammo": 0,

2
templates/level.html

@ -181,7 +181,7 @@ drone = Drone(maps[{{level['id']-1}}])
if(wind.frequency == "random"){
$("#wind_frequency").html("randomly");
}else{
$("#wind_frequency").html(wind.frequency+" every Drone move(s)");
$("#wind_frequency").html("every "+wind.frequency+" Drone move(s)");
}
}

Loading…
Cancel
Save