• R/O
  • SSH

silny-kombat: Commit

Mercurial repo for silny-kombat project


Commit MetaInfo

Revision887161379e1b92399794e09ce231aa23e3e34532 (tree)
Time2021-01-14 07:34:04
AuthorSecT
CommiterSecT

Log Message

Move right/left on key press

Change Summary

Incremental Difference

diff -r 96bbd6391344 -r 887161379e1b src/main.rs
--- a/src/main.rs Wed Jan 13 21:41:54 2021 +0100
+++ b/src/main.rs Wed Jan 13 23:34:04 2021 +0100
@@ -2,7 +2,7 @@
22 graphics::{
33 Color, Font, Rect, RectangleShape, RenderTarget, RenderWindow, Shape, Text, Transformable, Image, Sprite,Texture
44 },
5- system::Vector2,
5+ system::Vector2, system::Vector2f,
66 window::{mouse, ContextSettings, Cursor, CursorType::*, Event, Style, Key},
77 };
88
@@ -36,6 +36,18 @@
3636 | Event::KeyPressed {
3737 code: Key::ESCAPE, ..
3838 } => return,
39+ Event::KeyPressed {
40+ code: Key::RIGHT, ..
41+ } => {
42+ let v = Vector2f::new(1.0,0.0);
43+ sprite.move_(v);
44+ },
45+ Event::KeyPressed {
46+ code: Key::LEFT, ..
47+ } => {
48+ let v = Vector2f::new(-1.0,0.0);
49+ sprite.move_(v);
50+ },
3951 _ => {}
4052 }
4153 }
Show on old repository browser