Permalink
Browse files

[SRC] More documentation, minor update to game.path

  • Loading branch information...
1 parent 0a69928 commit dce06015ba2696f08af80eee5cf8decaa8acc139 @DannyArends committed May 20, 2012
Showing with 45 additions and 57 deletions.
  1. +10 −21 src/game/path.d
  2. +3 −3 src/game/search.d
  3. +10 −4 src/gui/hudhandler.d
  4. +4 −12 src/gui/motion.d
  5. +10 −4 src/gui/mytimer.d
  6. +2 −7 src/gui/physics.d
  7. +6 −6 src/sfx/formats/wav.d
View
@@ -15,27 +15,16 @@ import std.conv;
alias Point Step;
class Path{
-
-public:
- uint getLength(){
- return cast(uint)steps.length;
- }
-
- void appendStep(int x, int y){
- steps = steps ~ Step(x,y);
- }
-
- void prependStep(int x, int y){
- steps = Step(x,y) ~ steps;
- }
+ public:
+ uint length(){ return cast(uint)steps.length; }
+ void append(Step step){ steps = steps ~ step; }
+ void prepend(Step step){ steps = step ~ steps; }
- bool contains(int x, int y){
- foreach(Step s ; steps){
- if(s.x==x && s.y==y) return true;
+ bool contains(Step step){
+ foreach(Step s ; steps){ if(s.x==step.x && s.y==step.y){ return true; } }
+ return false;
}
- return false;
- }
-
-private:
- Step[] steps;
+
+ private:
+ Step[] steps;
}
View
@@ -141,14 +141,14 @@ class AStarSearch{
Path path = new Path();
Node target = nodes[tx][ty];
while (target != nodes[sx][sy]) {
- path.prependStep(target.x, target.y);
+ path.prepend(Step(target.x, target.y));
target = target.getParent();
}
- path.prependStep(sx,sy);
+ path.prepend(Step(sx,sy));
return path;
}
- private:
+ private:
Node[] mostLikelyOnTop(Node[] nodelist){
return nodelist;
}
View
@@ -1,9 +1,15 @@
+/******************************************************************//**
+ * \file src/gui/hudhandler.d
+ * \brief HUD Handler used by the main menu and some games
+ *
+ * <i>Copyright (c) 2012</i> Danny Arends<br>
+ * Last modified Mar, 2012<br>
+ * First written Dec, 2011<br>
+ * Written in the D Programming Language (http://www.digitalmars.com/d)
+ **********************************************************************/
module gui.hudhandler;
-import std.array;
-import std.stdio;
-import std.conv;
-
+import std.array, std.stdio, std.conv;
import sdl.sdlstructs;
import core.typedefs.types;
View
@@ -9,18 +9,10 @@
**********************************************************************/
module gui.motion;
-import std.array;
-import std.stdio;
-import std.math;
-import std.conv;
-
+import std.array, std.stdio, std.math, std.conv;
import sdl.sdlstructs;
-
-import core.typedefs.types;
-import core.typedefs.camera;
-import core.events.engine;
-import core.events.keyevent;
-import core.events.mouseevent;
+import core.typedefs.types, core.typedefs.camera;
+import core.events.engine, core.events.keyevent, core.events.mouseevent;
import gui.screen;
import gui.objects.object3d;
@@ -29,7 +21,7 @@ class CameraMotion : EventHandler{
@property Screen screen(){ return scr; }
private:
- Screen scr;
+ Screen scr;
}
class NoMotion : CameraMotion {
View
@@ -1,9 +1,15 @@
+/******************************************************************//**
+ * \file src/gui/mytimer.d
+ * \brief Definitions of TimedEvent and MyTimer
+ *
+ * <i>Copyright (c) 2012</i> Danny Arends<br>
+ * Last modified May, 2012<br>
+ * First written Dec, 2011<br>
+ * Written in the D Programming Language (http://www.digitalmars.com/d)
+ **********************************************************************/
module gui.mytimer;
-import std.array;
-import std.stdio;
-import std.conv;
-
+import std.array, std.stdio, std.conv;
import sdl.sdlfunctions;
import gl.gl_1_0;
View
@@ -9,14 +9,9 @@
**********************************************************************/
module gui.physics;
-import std.array;
-import std.stdio;
-import std.conv;
-
+import std.array, std.stdio, std.conv;
import sdl.sdlstructs;
-
-import core.events.engine;
-import core.events.keyevent;
+import core.events.engine, core.events.keyevent;
import gui.screen;
class Physics : EventHandler{
View
@@ -49,15 +49,15 @@ void unloadSound(wavInfo sound){
wavInfo loadSound(SFXEngine engine, string filename, bool verbose){
wavInfo sound = wavInfo(filename);
if(!exists(filename) || !filename.isFile){
- writefln("No such file: %s",filename);
+ writefln("[WAV] No such file: %s",filename);
sound.status = WavType.NO_SUCH_FILE;
return sound;
}
- if(verbose) writefln("Opening wav-file: %s",filename);
+ if(verbose) writefln("[WAV] Opening file: %s",filename);
alGenBuffers(1, &sound.Buffer);
if(alGetError() != AL_NO_ERROR){
- writeln("No Buffer available for sound");
+ writeln("[WAV] No Buffer available for sound");
sound.status = WavType.MEMORY;
return sound;
}
@@ -68,7 +68,7 @@ wavInfo loadSound(SFXEngine engine, string filename, bool verbose){
alGenSources(1, &sound.Source);
if(alGetError() != AL_NO_ERROR){
- writeln("No Source available for sound");
+ writeln("[WAV] No Source available for sound");
sound.status = WavType.READING_FILE;
return sound;
}
@@ -81,12 +81,12 @@ wavInfo loadSound(SFXEngine engine, string filename, bool verbose){
alSourcei (sound.Source, AL_LOOPING, sound.loop);
if(alGetError() != AL_NO_ERROR){
- writeln("Unable to bind sound source");
+ writeln("[WAV] Unable to bind sound source");
sound.status = WavType.BINDING_FILE;
return sound;
}
- if(verbose) writeln("Sound loaded");
+ if(verbose) writefln("[WAV] Sound %s loaded", filename);
sound.status = WavType.OK;
return sound;
}

0 comments on commit dce0601

Please sign in to comment.