Only consider it a store if it sells something edible or quaffable...

and reduce some of the vehicle parameters to make it easier to tune.
This commit is contained in:
Dustin Carlino 2020-12-16 17:57:27 -08:00
parent 3ef1e03279
commit e13dd74ab4
4 changed files with 22 additions and 22 deletions

View File

@ -243,7 +243,7 @@ fn make_vehicle_panel(ctx: &mut EventCtx, app: &App) -> Panel {
custom_bar(
ctx,
app.session.colors.boost,
vehicle.normal_speed / max_speed,
vehicle.speed / max_speed,
Text::new(),
)
.align_right(),

View File

@ -1,5 +1,6 @@
use std::collections::{HashMap, HashSet};
use map_gui::tools::amenity_type;
use map_model::{BuildingID, BuildingType};
use widgetry::{Color, Drawable, EventCtx, GeomBatch, Line, Text};
@ -65,8 +66,13 @@ impl Buildings {
}
continue;
}
} else if !b.amenities.is_empty() {
// TODO Maybe just food?
} else if b.amenities.iter().any(|a| {
if let Some(at) = amenity_type(&a.amenity_type) {
at == "groceries" || at == "food" || at == "bar"
} else {
false
}
}) {
buildings.insert(b.id, BldgState::Store);
batch.push(colors.store, b.polygon.clone());
continue;

View File

@ -18,8 +18,10 @@ use crate::player::Player;
use crate::vehicles::Vehicle;
use crate::{App, Transition};
const MAX_BOOST: Duration = Duration::const_seconds(5.0);
const ACQUIRE_BOOST_RATE: f64 = 0.5;
const BOOST_SPEED_MULTIPLIER: f64 = 2.0;
const HANGRY_SPEED_MULTIPLIER: f64 = 0.3;
pub struct Game {
title_panel: Panel,
@ -185,7 +187,7 @@ impl Game {
let boost_bar = custom_bar(
ctx,
app.session.colors.boost,
self.state.boost / self.state.vehicle.max_boost,
self.state.boost / MAX_BOOST,
if self.state.boost == Duration::ZERO {
Text::from(Line("Find a bike or bus lane"))
} else {
@ -205,9 +207,9 @@ impl Game {
self.update_time_panel(ctx, app);
let base_speed = if self.state.has_energy() {
self.state.vehicle.normal_speed
self.state.vehicle.speed
} else {
self.state.vehicle.tired_speed
HANGRY_SPEED_MULTIPLIER * self.state.vehicle.speed
};
let speed = if ctx.is_key_down(Key::Space) && self.state.boost > Duration::ZERO {
if !self.player.on_good_road(app) {
@ -291,7 +293,7 @@ impl Game {
if self.player.on_good_road(app) && !ctx.is_key_down(Key::Space) {
self.state.boost += dt * ACQUIRE_BOOST_RATE;
self.state.boost = self.state.boost.min(self.state.vehicle.max_boost);
self.state.boost = self.state.boost.min(MAX_BOOST);
}
self.animator.event(ctx, app.time);
@ -342,7 +344,7 @@ impl State<App> for Game {
self.animator.event(ctx, app.time);
self.snow.event(ctx, app.time);
self.player.override_pos(self.player.get_pos().project_away(
dt * self.state.vehicle.normal_speed,
dt * self.state.vehicle.speed,
self.player.get_angle().opposite(),
));
}

View File

@ -1,13 +1,11 @@
use geom::{Duration, Speed, Time};
use geom::{Speed, Time};
use widgetry::{GeomBatch, Prerender};
pub struct Vehicle {
pub name: String,
pub normal_speed: Speed,
pub tired_speed: Speed,
pub speed: Speed,
pub max_energy: usize,
pub max_boost: Duration,
// Paths to SVGs to draw in sequence
draw_frames: Vec<&'static str>,
@ -20,10 +18,8 @@ impl Vehicle {
"sleigh" => Vehicle {
name: "sleigh".to_string(),
normal_speed: Speed::miles_per_hour(30.0),
tired_speed: Speed::miles_per_hour(10.0),
speed: Speed::miles_per_hour(30.0),
max_energy: 20,
max_boost: Duration::seconds(5.0),
draw_frames: vec!["sleigh.svg"],
scale: 0.08,
@ -31,10 +27,8 @@ impl Vehicle {
"bike" => Vehicle {
name: "bike".to_string(),
normal_speed: Speed::miles_per_hour(40.0),
tired_speed: Speed::miles_per_hour(15.0),
speed: Speed::miles_per_hour(40.0),
max_energy: 50,
max_boost: Duration::seconds(8.0),
draw_frames: vec!["bike1.svg", "bike2.svg", "bike1.svg", "bike3.svg"],
scale: 0.05,
@ -42,10 +36,8 @@ impl Vehicle {
"cargo bike" => Vehicle {
name: "cargo bike".to_string(),
normal_speed: Speed::miles_per_hour(40.0),
tired_speed: Speed::miles_per_hour(5.0),
speed: Speed::miles_per_hour(40.0),
max_energy: 150,
max_boost: Duration::seconds(10.0),
draw_frames: vec![
"cargo_bike1.svg",
@ -77,7 +69,7 @@ impl Vehicle {
let mut energy = 0;
for x in vec!["bike", "cargo bike", "sleigh"] {
let vehicle = Vehicle::get(x);
speed = speed.max(vehicle.normal_speed);
speed = speed.max(vehicle.speed);
energy = energy.max(vehicle.max_energy);
}
(speed, energy)