changeset 8:156a95e4c018

final package structure now, i hope
author fred@reichbier.de
date Sat, 19 Jul 2008 17:26:41 +0200
parents 806b3781f4e4
children adc5e1eedb8a
files import/myrrdin/consumer.d import/myrrdin/consumers/consumer.d import/myrrdin/consumers/sprite.d import/myrrdin/consumers/tile.d import/myrrdin/consumers/view.d import/myrrdin/movingfigure.d import/myrrdin/renderer.d import/myrrdin/sprite.d import/myrrdin/spriteconsumer.d import/myrrdin/tileconsumer.d import/myrrdin/viewconsumer.d test/movingfigure/movingfigure.d test/view/viewconsumer.d
diffstat 13 files changed, 247 insertions(+), 257 deletions(-) [+]
line wrap: on
line diff
--- a/import/myrrdin/consumer.d	Sat Jul 19 15:21:09 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
-    myrrdin, a 2d tile engine
-    Copyright (c) 2008 Friedrich Weber
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE.
- */
-
-module myrrdin.consumer;
-
-import dsfml.window.all;
-import dsfml.system.all;
-import dsfml.graphics.all;
-
-import myrrdin.renderer;
-
-class Consumer {
-    protected Renderer renderer;
-
-    this(Renderer renderer) {
-	this.renderer = renderer;
-    }
-
-    /* handle the event `evt`. Return true if the event was handled and should not
-       be propagated any further, otherwise false */
-    bool handle_event(Event evt) {
-	return false;
-    }
-
-    /* draw all the content of this with this.app.draw(stuff) */
-    void draw() {
-
-    }
-
-    /* called for each loop iteration */
-    void loop_iteration() {
-    
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/import/myrrdin/consumers/consumer.d	Sat Jul 19 17:26:41 2008 +0200
@@ -0,0 +1,54 @@
+/*
+    myrrdin, a 2d tile engine
+    Copyright (c) 2008 Friedrich Weber
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
+ */
+
+module myrrdin.consumers.consumer;
+
+import dsfml.window.all;
+import dsfml.system.all;
+import dsfml.graphics.all;
+
+import myrrdin.renderer;
+
+class Consumer {
+    protected Renderer renderer;
+
+    this(Renderer renderer) {
+	this.renderer = renderer;
+    }
+
+    /* handle the event `evt`. Return true if the event was handled and should not
+       be propagated any further, otherwise false */
+    bool handle_event(Event evt) {
+	return false;
+    }
+
+    /* draw all the content of this with this.app.draw(stuff) */
+    void draw() {
+
+    }
+
+    /* called for each loop iteration */
+    void loop_iteration() {
+    
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/import/myrrdin/consumers/sprite.d	Sat Jul 19 17:26:41 2008 +0200
@@ -0,0 +1,51 @@
+/*
+    myrrdin, a 2d tile engine
+    Copyright (c) 2008 Friedrich Weber
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the Software), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
+ */
+
+module myrrdin.consumers.sprite;
+
+import dsfml.window.all;
+import dsfml.system.all;
+import dsfml.graphics.all;
+
+import myrrdin.animatedsprite;
+import myrrdin.consumers.consumer;
+import myrrdin.renderer;
+
+class SpriteConsumer : Consumer {
+    private Sprite[] sprites;
+
+    this(Renderer renderer) {
+	super(renderer);
+    }
+
+    void add_sprite(Sprite sprite) {
+	this.sprites ~= sprite;
+    }
+
+    void draw() {
+	 foreach(Sprite sprite; this.sprites) { 
+	    this.renderer.draw(sprite);
+	 }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/import/myrrdin/consumers/tile.d	Sat Jul 19 17:26:41 2008 +0200
@@ -0,0 +1,61 @@
+/*
+    myrrdin, a 2d tile engine
+    Copyright (c) 2008 Friedrich Weber
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the Software), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
+ */
+
+module myrrdin.consumers.tile;
+
+import dsfml.window.all;
+import dsfml.system.all;
+import dsfml.graphics.all;
+import tango.io.Stdout;
+
+import myrrdin.consumers.consumer;
+import myrrdin.renderer;
+import myrrdin.tileset;
+import myrrdin.tilemap;
+
+class TileConsumer : Consumer {
+    public Tilemap map;
+
+    this(Renderer renderer, Tilemap map) {
+	super(renderer);
+	this.map = map;
+    }
+
+    void draw() {
+	 foreach(Sprite sprite; this.map.get_sprites()) {
+	    this.renderer.draw(sprite);
+	 }
+    }
+
+    bool handle_event(Event evt) {
+	if (evt.Type == Event.EventType.MOUSEBUTTONPRESSED) {
+	    Input input = this.renderer.app.getInput();
+	    Vector2i tile = this.map.real_to_tile(0, input.getMouseX(), input.getMouseY());
+	    if(this.map.has_tile(0, tile.x, tile.y)) {
+		Stdout.formatln("You clicked on the tile {}, {}", tile.x, tile.y);
+	    }
+	    return true;
+	}	    
+	return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/import/myrrdin/consumers/view.d	Sat Jul 19 17:26:41 2008 +0200
@@ -0,0 +1,75 @@
+/*
+    myrrdin, a 2d tile engine
+    Copyright (c) 2008 Friedrich Weber
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the Software), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
+ */
+
+module myrrdin.consumers.view;
+
+import dsfml.window.all;
+import dsfml.system.all;
+import dsfml.graphics.all;
+
+import myrrdin.consumers.consumer;
+import myrrdin.renderer;
+import tango.io.Stdout;
+
+/* That is a consumer which sets and manipulates the render window view */
+class ViewConsumer : Consumer {
+    protected View view;
+
+    this(Renderer renderer) {
+	super(renderer);
+	// set the initial view
+	this.view = renderer.app.getView();
+	this.view.setFromRect(new FloatRect(0, 0, renderer.app.getWidth(), renderer.app.getHeight()));
+	this.update_view();
+    }
+
+    protected void update_view() {
+	this.renderer.app.setView(this.view);
+    }
+
+    void move_view(float x=0, float y=0) {
+	this.view.move(x, y);
+    }
+}
+
+class InteractiveViewConsumer : ViewConsumer {
+    this(Renderer renderer) {
+	super(renderer);
+    }
+
+    bool handle_event(Event evt) {
+	if (evt.Type == Event.EventType.KEYPRESSED) {
+	    float x=0, y=0;
+	    if(evt.Key.Code == KeyCode.LEFT) x -= 2;
+	    if(evt.Key.Code == KeyCode.RIGHT) x += 2;
+	    if(evt.Key.Code == KeyCode.UP) y -= 2;
+	    if(evt.Key.Code == KeyCode.DOWN) y += 2;
+	    if(x != 0 || y != 0) {
+		Stdout.formatln("{} fps", 1.0 / this.renderer.app.getFrameTime());
+		this.move_view(x, y);
+		return true;
+	    }
+	}
+	return false;
+    }
+}
--- a/import/myrrdin/movingfigure.d	Sat Jul 19 15:21:09 2008 +0200
+++ b/import/myrrdin/movingfigure.d	Sat Jul 19 17:26:41 2008 +0200
@@ -29,7 +29,7 @@
 import dsfml.system.all;
 import dsfml.graphics.all;
 
-import myrrdin.spriteconsumer;
+import myrrdin.consumers.sprite;
 import myrrdin.animatedsprite;
 import myrrdin.renderer;
 import myrrdin.imagecache;
--- a/import/myrrdin/renderer.d	Sat Jul 19 15:21:09 2008 +0200
+++ b/import/myrrdin/renderer.d	Sat Jul 19 17:26:41 2008 +0200
@@ -27,7 +27,7 @@
 import dsfml.system.all;
 import dsfml.graphics.all;
 
-import myrrdin.consumer;
+import myrrdin.consumers.consumer;
 import myrrdin.imagecache;
 import myrrdin.animatedsprite;
 
--- a/import/myrrdin/sprite.d	Sat Jul 19 15:21:09 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-module myrrdin.sprite;
-
-import dsfml.window.all;
-import dsfml.system.all;
-import dsfml.graphics.all : Sprite = SFSprite;
-
-import myrrdin.renderer;
--- a/import/myrrdin/spriteconsumer.d	Sat Jul 19 15:21:09 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
-    myrrdin, a 2d tile engine
-    Copyright (c) 2008 Friedrich Weber
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the Software), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE.
- */
-
-module myrrdin.spriteconsumer;
-
-import dsfml.window.all;
-import dsfml.system.all;
-import dsfml.graphics.all;
-
-import myrrdin.animatedsprite;
-import myrrdin.consumer;
-import myrrdin.renderer;
-
-class SpriteConsumer : Consumer {
-    private Sprite[] sprites;
-
-    this(Renderer renderer) {
-	super(renderer);
-    }
-
-    void add_sprite(Sprite sprite) {
-	this.sprites ~= sprite;
-    }
-
-    void draw() {
-	 foreach(Sprite sprite; this.sprites) { 
-	    this.renderer.draw(sprite);
-	 }
-    }
-}
-
--- a/import/myrrdin/tileconsumer.d	Sat Jul 19 15:21:09 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
-    myrrdin, a 2d tile engine
-    Copyright (c) 2008 Friedrich Weber
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the Software), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE.
- */
-
-module myrrdin.tileconsumer;
-
-import dsfml.window.all;
-import dsfml.system.all;
-import dsfml.graphics.all;
-import tango.io.Stdout;
-
-import myrrdin.consumer;
-import myrrdin.renderer;
-import myrrdin.tileset;
-import myrrdin.tilemap;
-
-class TileConsumer : Consumer {
-    public Tilemap map;
-
-    this(Renderer renderer, Tilemap map) {
-	super(renderer);
-	this.map = map;
-    }
-
-    void draw() {
-	 foreach(Sprite sprite; this.map.get_sprites()) {
-	    this.renderer.draw(sprite);
-	 }
-    }
-
-    bool handle_event(Event evt) {
-	if (evt.Type == Event.EventType.MOUSEBUTTONPRESSED) {
-	    Input input = this.renderer.app.getInput();
-	    Vector2i tile = this.map.real_to_tile(0, input.getMouseX(), input.getMouseY());
-	    if(this.map.has_tile(0, tile.x, tile.y)) {
-		Stdout.formatln("You clicked on the tile {}, {}", tile.x, tile.y);
-	    }
-	    return true;
-	}	    
-	return false;
-    }
-}
--- a/import/myrrdin/viewconsumer.d	Sat Jul 19 15:21:09 2008 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
-    myrrdin, a 2d tile engine
-    Copyright (c) 2008 Friedrich Weber
-
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the Software), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-    THE SOFTWARE.
- */
-
-module myrrdin.viewconsumer;
-
-import dsfml.window.all;
-import dsfml.system.all;
-import dsfml.graphics.all;
-
-import myrrdin.consumer;
-import myrrdin.renderer;
-import tango.io.Stdout;
-
-/* That is a consumer which sets and manipulates the render window view */
-class ViewConsumer : Consumer {
-    protected View view;
-
-    this(Renderer renderer) {
-	super(renderer);
-	// set the initial view
-	this.view = renderer.app.getView();
-	this.view.setFromRect(new FloatRect(0, 0, renderer.app.getWidth(), renderer.app.getHeight()));
-	this.update_view();
-    }
-
-    protected void update_view() {
-	this.renderer.app.setView(this.view);
-    }
-
-    void move_view(float x=0, float y=0) {
-	this.view.move(x, y);
-    }
-}
-
-class InteractiveViewConsumer : ViewConsumer {
-    this(Renderer renderer) {
-	super(renderer);
-    }
-
-    bool handle_event(Event evt) {
-	if (evt.Type == Event.EventType.KEYPRESSED) {
-	    float x=0, y=0;
-	    if(evt.Key.Code == KeyCode.LEFT) x -= 2;
-	    if(evt.Key.Code == KeyCode.RIGHT) x += 2;
-	    if(evt.Key.Code == KeyCode.UP) y -= 2;
-	    if(evt.Key.Code == KeyCode.DOWN) y += 2;
-	    if(x != 0 || y != 0) {
-		Stdout.formatln("{} fps", 1.0 / this.renderer.app.getFrameTime());
-		this.move_view(x, y);
-		return true;
-	    }
-	}
-	return false;
-    }
-}
--- a/test/movingfigure/movingfigure.d	Sat Jul 19 15:21:09 2008 +0200
+++ b/test/movingfigure/movingfigure.d	Sat Jul 19 17:26:41 2008 +0200
@@ -23,7 +23,7 @@
 
 module testmovingfigure;
 
-import myrrdin.tileconsumer;
+import myrrdin.consumers.tile;
 import myrrdin.renderer;
 import myrrdin.imagecache;
 import myrrdin.tilemap;
@@ -31,7 +31,7 @@
 import myrrdin.xmlmap;
 import myrrdin.tools;
 import myrrdin.animatedsprite;
-import myrrdin.spriteconsumer;
+import myrrdin.consumers.sprite;
 import myrrdin.movingfigure;
 
 int main(char[][] args) {
--- a/test/view/viewconsumer.d	Sat Jul 19 15:21:09 2008 +0200
+++ b/test/view/viewconsumer.d	Sat Jul 19 17:26:41 2008 +0200
@@ -27,18 +27,15 @@
 import dsfml.system.all;
 import dsfml.graphics.all;
 
-import myrrdin.tileconsumer;
+import myrrdin.consumers.tile;
 import myrrdin.renderer;
-import myrrdin.consumer;
 import myrrdin.imagecache;
 import myrrdin.tilemap;
 import myrrdin.tileset;
 import myrrdin.xmlmap;
 import myrrdin.tools;
-import myrrdin.viewconsumer;
+import myrrdin.consumers.view;
 import myrrdin.animatedsprite;
-import myrrdin.spriteconsumer;
-import myrrdin.movingfigure;
 
 int main(char[][] args) {
     Cache cache = new Cache("gfx");