Browse Source

upgrade to ggez 6.0rc1

Bastien Sevajol 3 years ago
parent
commit
69dca4a6f2
6 changed files with 967 additions and 703 deletions
  1. 1 0
      .gitignore
  2. 948 683
      Cargo.lock
  3. 2 4
      Cargo.toml
  4. BIN
      resources/map1bg.png
  5. BIN
      resources/test.png
  6. 16 16
      src/main.rs

+ 1 - 0
.gitignore View File

@@ -1,2 +1,3 @@
1 1
 /target
2 2
 .idea
3
+*~

File diff suppressed because it is too large
+ 948 - 683
Cargo.lock


+ 2 - 4
Cargo.toml View File

@@ -4,8 +4,6 @@ version = "0.1.0"
4 4
 authors = ["Sevajol Bastien <contact@bux.fr>"]
5 5
 edition = "2018"
6 6
 
7
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
-
9 7
 [dependencies]
10
-ggez = "0.5.1"
11
-glam = "0.14.0"
8
+ggez = { git = "https://github.com/ggez/ggez", tag = "0.6.0-rc0" }
9
+glam = "0.12.0"

BIN
resources/map1bg.png View File


BIN
resources/test.png View File


+ 16 - 16
src/main.rs View File

@@ -2,7 +2,6 @@ use ggez;
2 2
 use ggez::event::KeyCode;
3 3
 use ggez::graphics;
4 4
 use ggez::graphics::{DrawMode, MeshBuilder};
5
-use ggez::nalgebra as na;
6 5
 use ggez::timer::check_update_time;
7 6
 use ggez::{event, input};
8 7
 use ggez::{Context, GameResult};
@@ -10,6 +9,7 @@ use glam::Vec2;
10 9
 use std::env;
11 10
 use std::path;
12 11
 
12
+type Point2 = Vec2;
13 13
 type Vector2 = Vec2;
14 14
 
15 15
 const TARGET_FPS: u32 = 60; // execute update code 60x per seconds
@@ -90,14 +90,14 @@ impl ItemState {
90 90
 }
91 91
 
92 92
 struct SceneItem {
93
-    position: na::Point2<f32>,
93
+    position: Point2,
94 94
     state: ItemState,
95 95
     meta_events: Vec<MetaEvent>,
96 96
     current_frame: u16,
97 97
 }
98 98
 
99 99
 impl SceneItem {
100
-    pub fn new(position: na::Point2<f32>, state: ItemState) -> Self {
100
+    pub fn new(position: Point2, state: ItemState) -> Self {
101 101
         let sprite_type = state.sprite_type();
102 102
         Self {
103 103
             position,
@@ -129,7 +129,7 @@ impl SceneItem {
129 129
                 sprite_info.relative_tile_height,
130 130
             ))
131 131
             .rotation(90.0f32.to_radians())
132
-            .offset(na::Point2::new(0.5, 0.5))
132
+            .offset(Point2::new(0.5, 0.5))
133 133
     }
134 134
 }
135 135
 
@@ -147,7 +147,7 @@ struct MainState {
147 147
     map_batch: graphics::spritebatch::SpriteBatch,
148 148
     scene_items: Vec<SceneItem>,
149 149
     physics_events: Vec<PhysicEvent>,
150
-    display_offset: na::Point2<f32>,
150
+    display_offset: Point2,
151 151
 }
152 152
 
153 153
 impl MainState {
@@ -167,7 +167,7 @@ impl MainState {
167 167
                 };
168 168
 
169 169
                 scene_items.push(SceneItem::new(
170
-                    na::Point2::new((x as f32 * 24.0) + 100.0, (y as f32 * 24.0) + 100.0),
170
+                    Point2::new((x as f32 * 24.0) + 100.0, (y as f32 * 24.0) + 100.0),
171 171
                     ItemState::new(current_behavior),
172 172
                 ));
173 173
             }
@@ -179,7 +179,7 @@ impl MainState {
179 179
             map_batch,
180 180
             scene_items,
181 181
             physics_events: vec![],
182
-            display_offset: na::Point2::new(0.0, 0.0),
182
+            display_offset: Point2::new(0.0, 0.0),
183 183
         };
184 184
         Ok(s)
185 185
     }
@@ -274,8 +274,8 @@ impl MainState {
274 274
         }
275 275
     }
276 276
 
277
-    fn position_with_display_offset(&self, position: &na::Point2<f32>) -> na::Point2<f32> {
278
-        na::Point2::new(
277
+    fn position_with_display_offset(&self, position: &Point2) -> Point2 {
278
+        Point2::new(
279 279
             position.x + self.display_offset.x,
280 280
             position.y + self.display_offset.y,
281 281
         )
@@ -344,12 +344,12 @@ impl event::EventHandler for MainState {
344 344
                 2.0,
345 345
                 2.0,
346 346
                 graphics::WHITE,
347
-            );
347
+            )?;
348 348
         }
349 349
         self.map_batch.add(
350 350
             graphics::DrawParam::new()
351 351
                 .src(graphics::Rect::new(0.0, 0.0, 1.0, 1.0))
352
-                .dest(na::Point2::new(0.0, 0.0)),
352
+                .dest(Point2::new(0.0, 0.0)),
353 353
         );
354 354
 
355 355
         let mesh = mesh_builder.build(ctx)?;
@@ -357,19 +357,19 @@ impl event::EventHandler for MainState {
357 357
             ctx,
358 358
             &self.map_batch,
359 359
             graphics::DrawParam::new()
360
-                .dest(self.position_with_display_offset(&na::Point2::new(0.0, 0.0))),
360
+                .dest(self.position_with_display_offset(&Point2::new(0.0, 0.0))),
361 361
         )?;
362 362
         graphics::draw(
363 363
             ctx,
364 364
             &self.sprite_sheet_batch,
365 365
             graphics::DrawParam::new()
366
-                .dest(self.position_with_display_offset(&na::Point2::new(0.0, 0.0))),
366
+                .dest(self.position_with_display_offset(&Point2::new(0.0, 0.0))),
367 367
         )?;
368 368
         graphics::draw(
369 369
             ctx,
370 370
             &mesh,
371 371
             graphics::DrawParam::new()
372
-                .dest(self.position_with_display_offset(&na::Point2::new(0.0, 0.0))),
372
+                .dest(self.position_with_display_offset(&Point2::new(0.0, 0.0))),
373 373
         )?;
374 374
 
375 375
         self.sprite_sheet_batch.clear();
@@ -393,8 +393,8 @@ pub fn main() -> GameResult {
393 393
     let cb = ggez::ContextBuilder::new("oc", "bux")
394 394
         .add_resource_path(resource_dir)
395 395
         .window_mode(ggez::conf::WindowMode::default().dimensions(800.0, 600.0));
396
-    let (ctx, event_loop) = &mut cb.build()?;
396
+    let (mut ctx, event_loop) = cb.build()?;
397 397
 
398
-    let state = &mut MainState::new(ctx)?;
398
+    let state = MainState::new(&mut ctx)?;
399 399
     event::run(ctx, event_loop, state)
400 400
 }