~ubuntu-branches/ubuntu/wily/swell-foop/wily

« back to all changes in this revision

Viewing changes to src/game-view.vala

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2015-05-19 14:54:40 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150519145440-5gvlqn2aijuq2xzw
Tags: 1:3.16.1-1
* New upstream release.
* Switch build-dependency from appdata-tools to appstream-util

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    public int cursor_x
26
26
    {
27
27
        get { return this._cursor_x; }
28
 
        set { this._cursor_x = value.clamp(0, game.columns - 1); }
 
28
        set { this._cursor_x = value.clamp (0, game.columns - 1); }
29
29
    }
30
30
 
31
31
    private int _cursor_y;
32
32
    public int cursor_y
33
33
    {
34
34
        get { return this._cursor_y; }
35
 
        set { this._cursor_y = value.clamp(0, game.rows - 1); }
 
35
        set { this._cursor_y = value.clamp (0, game.rows - 1); }
36
36
    }
37
37
 
38
38
    /* A 2D array holding all tiles */
260
260
        return false;
261
261
    }
262
262
 
 
263
    private TileActor? find_tile_at_position (int position_x, int position_y)
 
264
    {
 
265
        foreach (TileActor actor in tiles)
 
266
            if (actor.tile.grid_x == position_x &&
 
267
                actor.tile.grid_y == position_y)
 
268
                return actor;
 
269
        return null;
 
270
    }
 
271
 
263
272
    /* Move Keyboard cursor */
264
273
    public void cursor_move (int x, int y)
265
274
    {
268
277
        opacity_for_connected_tiles (highlighted, 180);
269
278
        cursor_x += x;
270
279
        cursor_y += y;
271
 
        highlighted = tiles[cursor_x, cursor_y];
272
 
        opacity_for_connected_tiles (highlighted, 255);
 
280
        highlighted = find_tile_at_position (cursor_x, cursor_y);
 
281
 
 
282
        if (highlighted != null)
 
283
            opacity_for_connected_tiles (highlighted, 255);
273
284
 
274
285
        float xx, yy;
275
286
        xx = cursor_x * tile_size;
390
401
        var anim_mode = is_zealous ? Clutter.AnimationMode.EASE_OUT_BOUNCE : Clutter.AnimationMode.EASE_OUT_QUAD;
391
402
        set_easing_mode (anim_mode);
392
403
        set_easing_duration (500);
393
 
        set_position ( (float)new_x, (float)new_y);
 
404
        set_position ((float) new_x, (float) new_y);
394
405
    }
395
406
}
396
407
 
429
440
        pivot_point.x = 0.5f;
430
441
        pivot_point.y = 0.5f;
431
442
 
432
 
        this.scene_width = (float)width;
433
 
        this.scene_height = (float)height;
 
443
        this.scene_width = (float) width;
 
444
        this.scene_height = (float) height;
434
445
        this.game_size = game_size;
435
446
    }
436
447
 
440
451
            return;
441
452
 
442
453
        label.set_font_name ("Bitstrem Vera Sans Bold 30");
443
 
        label.set_text ("+" + points.to_string());
 
454
        label.set_text ("+" + points.to_string ());
444
455
 
445
456
        /* The score will be shown repeatedly therefore we need to reset some important properties
446
457
         * before the actual animation */