Commit 30d987c3 authored by Benjamin Lee's avatar Benjamin Lee 💬
Browse files

Added option to have players die when they touch their own cursor.

parent c0f888b5
......@@ -38,6 +38,7 @@ pub struct GameSettings {
pub ball_start_distance: f32,
pub ball_start_speed: f32,
pub bounds_radius: f32,
pub kill_own_cursor: bool,
}
impl Default for GameSettings {
......@@ -49,6 +50,7 @@ impl Default for GameSettings {
ball_start_distance: 0.3,
ball_start_speed: 1.0,
bounds_radius: 1.0,
kill_own_cursor: false,
}
}
}
......
......@@ -231,9 +231,9 @@ impl Game {
if let Some(cursor) = player.state.cursor {
let circle_cursor = physics::cursor(cursor, settings);
for (&id_ball, player_ball) in self.players.iter() {
if id == id_ball {
// Don't let players kill themselves.
// TODO make this configurable
if id == id_ball && !settings.kill_own_cursor {
// Don't let players kill themselves
// unless that setting is on.
continue;
}
......
......@@ -403,7 +403,6 @@ impl Server {
let dt = dt.as_float_secs() as f32;
self.timer.set_timeout(interval, TimeoutState::Tick);
debug!("stepping game tick (dt={})", dt);
let events = self.game.tick(dt);
self.send_events(events)?;
......
......@@ -15,7 +15,7 @@ use crate::networking::{
use easer::functions::*;
use gfx_hal::Backend;
use imgui::{im_str, ImString, Ui};
use log::{error, warn};
use log::{debug, error, warn};
use nalgebra::Point2;
use palette::LinSrgb;
use std::iter;
......@@ -557,7 +557,15 @@ impl GameState {
&mut settings.bounds_radius,
)
.build();
changed |= ui.checkbox(
im_str!("players can kill own cursor"),
&mut settings.kill_own_cursor,
);
if changed {
debug!(
"sending updated settings: {:?}",
settings
);
game.set_settings(settings);
}
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment