[gnome-nibbles] Rescale bonuses when resizing window
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles] Rescale bonuses when resizing window
- Date: Mon, 26 Oct 2015 00:15:58 +0000 (UTC)
commit 9422fdd7956a259b2daa53504f1c37e1a84847b5
Author: Iulian Radu <iulian radu67 gmail com>
Date: Wed Jul 1 19:36:37 2015 +0300
Rescale bonuses when resizing window
src/gnome-nibbles.vala | 1 +
src/nibbles-view.vala | 29 ++++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index 6cfe303..ac9fe6e 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -156,6 +156,7 @@ public class Nibbles : Gtk.Application
view.stage.set_size (tile_size * NibblesGame.WIDTH, tile_size * NibblesGame.HEIGHT);
view.board_rescale (tile_size);
+ view.boni_rescale (tile_size);
foreach (var worm in game.worms)
worm.rescaled (tile_size);
diff --git a/src/nibbles-view.vala b/src/nibbles-view.vala
index bc06eea..1319b4d 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -535,13 +535,40 @@ public class NibblesView : GtkClutter.Embed
}
actor.set_position (bonus.x * game.tile_size, bonus.y * game.tile_size);
- // actor.set_size (game.tile_size, game.tile_size);
stage.add_child (actor);
bonus_actors.set (bonus, actor);
}
+ public void boni_rescale (int tile_size)
+ {
+ float x_pos, y_pos;
+
+ foreach (var bonus in game.boni.bonuses)
+ {
+ var actor = bonus_actors.get (bonus);
+ actor.get_position (out x_pos, out y_pos);
+ actor.set_position ((x_pos / game.tile_size) * tile_size,
+ (y_pos / game.tile_size) * tile_size);
+
+ try
+ {
+ actor.set_from_pixbuf (boni_pixmaps[bonus.type]);
+ }
+ catch (Clutter.TextureError e)
+ {
+ /* Fatal console error when a texture could not be set. */
+ error (_("Nibbles failed to set texture: %s"), e.message);
+ }
+ catch (Error e)
+ {
+ /* Fatal console error when a texture could not be set. */
+ error (_("Nibbles failed to set texture: %s"), e.message);
+ }
+ }
+ }
+
public static int colorval_from_name (string name)
{
for (int i = 0; i < NUM_COLORS; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]