Mercurial > projects > myrrdin
annotate import/myrrdin/tileconsumer.d @ 5:f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
author | fred@reichbier.de |
---|---|
date | Sat, 19 Jul 2008 14:33:08 +0200 |
parents | src/tileconsumer.d@292df259cc85 |
children | 510541745cd1 |
rev | line source |
---|---|
5
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
1 /* |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
2 This file is part of myrrdin. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
3 |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
4 myrrdin is free software: you can redistribute it and/or modify |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
5 it under the terms of the GNU Lesser General Public License as |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
6 published by the Free Software Foundation, either version 3 of |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
7 the License, or (at your option) any later version. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
8 |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
9 myrrdin is distributed in the hope that it will be useful, |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
12 GNU Lesser General Public License for more details. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
13 |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
14 You should have received a copy of the GNU Lesser General Public |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
15 License along with myrrdin. If not, see <http://www.gnu.org/licenses/>. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
16 */ |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
17 |
0 | 18 module tileconsumer; |
19 | |
20 import dsfml.window.all; | |
21 import dsfml.system.all; | |
22 import dsfml.graphics.all; | |
5
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
23 import tango.io.Stdout; |
0 | 24 |
25 import consumer; | |
26 import renderer; | |
27 import tileset; | |
28 import tilemap; | |
29 | |
30 class TileConsumer : Consumer { | |
31 public Tilemap map; | |
32 | |
33 this(Renderer renderer, Tilemap map) { | |
34 super(renderer); | |
35 this.map = map; | |
36 } | |
37 | |
38 void draw() { | |
39 foreach(Sprite sprite; this.map.get_sprites()) { | |
4
292df259cc85
view + sprite consumers, animated sprite working
fred@reichbier.de
parents:
0
diff
changeset
|
40 this.renderer.draw(sprite); |
0 | 41 } |
42 } | |
5
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
43 |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
44 bool handle_event(Event evt) { |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
45 if (evt.Type == Event.EventType.MOUSEBUTTONPRESSED) { |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
46 Input input = this.renderer.app.getInput(); |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
47 Vector2i tile = this.map.real_to_tile(0, input.getMouseX(), input.getMouseY()); |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
48 if(this.map.has_tile(0, tile.x, tile.y)) { |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
49 Stdout.formatln("You clicked on the tile {}, {}", tile.x, tile.y); |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
50 } |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
51 return true; |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
52 } |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
53 return false; |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
4
diff
changeset
|
54 } |
0 | 55 } |