],
"ResourcesPath" : "",
"Resources" : [
- "dico.txt",
- "english.txt"
+ "res/dico.txt",
+ "res/english.txt"
]
}
\ No newline at end of file
-
-ECERE Project File
-
-Version 0.1a
-
-Target "tetris"
-
- Configurations
-
- + Debug
-
- Compiler Options
-
- Intermediate Directory = debug
- Debug = True
- Optimize = None
- Profile = False
- MemoryGuard = False
- AllWarnings = True
- Strict Name Spaces = False
-
- Linker Options
-
- Target Name = tetris
- Target Type = Executable
- Target Directory = debug
- Console = False
-
- Libraries = ecere
-
- + Release
-
- Compiler Options
-
- Intermediate Directory = release
- Debug = False
- Optimize = Speed
- Profile = False
- MemoryGuard = False
- AllWarnings = True
- Strict Name Spaces = False
-
- Linker Options
-
- Target Name = tetris
- Target Type = Executable
- Target Directory = release
- Console = False
-
- Libraries = ecere
-
- + memguard
-
- Compiler Options
-
- Intermediate Directory = memguard
- Debug = True
- Optimize = None
- Profile = False
- MemoryGuard = True
- AllWarnings = True
- Strict Name Spaces = False
-
- Linker Options
-
- Target Name = tetris
- Target Type = Executable
- Target Directory = memguard
- Console = False
-
- Libraries = memguard
-
- Files
-
- - tetris.ec
-
- Resources
-
- = data/tetris.bmp
+{
+ "Version" : 0.2,
+ "ModuleName" : "tetris",
+ "Options" : {
+ "Warnings" : "All",
+ "Profile" : false,
+ "StrictNameSpaces" : false,
+ "TargetType" : "Executable",
+ "Libraries" : [
+ "ecere"
+ ],
+ "Console" : false
+ },
+ "Configurations" : [
+ {
+ "Name" : "Debug",
+ "Options" : {
+ "Debug" : true,
+ "MemoryGuard" : false,
+ "Optimization" : "None",
+ "TargetFileName" : "tetris",
+ "TargetDirectory" : "debug",
+ "ObjectsDirectory" : "debug"
+ }
+ },
+ {
+ "Name" : "Release",
+ "Options" : {
+ "Debug" : false,
+ "MemoryGuard" : false,
+ "Optimization" : "Speed",
+ "TargetFileName" : "tetris",
+ "TargetDirectory" : "release",
+ "ObjectsDirectory" : "release"
+ }
+ },
+ {
+ "Name" : "memguard",
+ "Options" : {
+ "Debug" : true,
+ "MemoryGuard" : true,
+ "Optimization" : "None",
+ "TargetFileName" : "tetris",
+ "TargetDirectory" : "memguard",
+ "ObjectsDirectory" : "memguard"
+ }
+ }
+ ],
+ "Files" : [
+ "tetris.ec"
+ ],
+ "ResourcesPath" : "",
+ "Resources" : [
+ "res/tetris.bmp"
+ ]
+}
\ No newline at end of file
--- /dev/null
+import "ecere"
+
+class MainWindow : Window
+{
+ text = "Bitmap Demo";
+ background = black;
+ borderStyle = sizable;
+ hasMaximize = true;
+ hasMinimize = true;
+ hasClose = true;
+ size = { 576, 432 };
+
+ BitmapResource castleGfx { ":castle.png", window = this };
+
+ void OnRedraw(Surface surface)
+ {
+ Bitmap bitmap = castleGfx.bitmap;
+
+ if(bitmap)
+ surface.Blit(bitmap, 100, 100, 0,0, bitmap.width, bitmap.height);
+ }
+}
+
+MainWindow mainWindow {};
--- /dev/null
+{
+ "Version" : 0.2,
+ "ModuleName" : "BitmapAudioKB",
+ "Options" : {
+ "Warnings" : "All",
+ "TargetType" : "Executable",
+ "TargetFileName" : "bitmap",
+ "Libraries" : [
+ "ecere"
+ ]
+ },
+ "Configurations" : [
+ {
+ "Name" : "Debug",
+ "Options" : {
+ "Debug" : true,
+ "Optimization" : "None",
+ "PreprocessorDefinitions" : [
+ "_DEBUG"
+ ]
+ }
+ },
+ {
+ "Name" : "Release",
+ "Options" : {
+ "Debug" : false,
+ "Optimization" : "Speed"
+ }
+ }
+ ],
+ "Files" : [
+ "bitmap.ec"
+ ],
+ "ResourcesPath" : "",
+ "Resources" : [
+ "../res/castle.png"
+ ]
+}
\ No newline at end of file
--- /dev/null
+import "ecere"
+
+BitmapResource peasantGfx { ":peasant.png" };
+BitmapResource dragonGfx { ":dragon.png" };
+BitmapResource mageGfx { ":mage.png" };
+BitmapResource archerGfx { ":archer.png" };
+BitmapResource castleGfx { ":castle.png" };
+
+Array<BitmapResource> gfxResources { [ peasantGfx, dragonGfx, mageGfx, archerGfx, castleGfx ] };
+
+class WorldObject
+{
+ bool selectable;
+ BitmapResource res;
+
+ void Render(Surface surface)
+ {
+ Bitmap bmp = res ? res.bitmap : null;
+ if(bmp)
+ {
+ surface.Blit(bmp, x, y, 0,0, bmp.width, bmp.height);
+ if(this == selected)
+ {
+ surface.foreground = lime;
+ surface.Rectangle(x-1, y-1, x + bmp.width, y + bmp.height);
+ surface.foreground = white;
+ surface.Rectangle(x-2, y-2, x + bmp.width+1, y + bmp.height+1);
+ }
+ }
+ }
+
+public:
+ int x, y;
+}
+
+class Peasant : WorldObject { res = peasantGfx; selectable = true; }
+class Dragon : WorldObject { res = dragonGfx; }
+class Mage : WorldObject { res = mageGfx; selectable = true; }
+class Archer : WorldObject { res = archerGfx; selectable = true; }
+class Castle : WorldObject { res = castleGfx; }
+
+Array<WorldObject> objects
+{ [
+ Castle { 180, 150 },
+ Mage { 50, 50 },
+ Archer { 150, 250 },
+ Peasant { 380, 290 },
+ Peasant { 120, 150 },
+ Dragon { 320, 50 }
+] };
+
+WorldObject selected;
+
+class WorldObjectController : WindowController<WorldObject>
+{
+ bool OnKeyHit(WorldObjectController controller, Key key, unichar ch)
+ {
+ switch(key)
+ {
+ case tab:
+ {
+ Iterator<WorldObject> it { objects };
+ it.Find(selected);
+ do
+ {
+ if(!it.Next())
+ it.Next();
+ selected = it.data;
+ } while(!selected.selectable);
+ controller.controlled = selected;
+ break;
+ }
+ case left: x -= 5; break;
+ case right: x += 5; break;
+ case up: y -= 5; break;
+ case down: y += 5; break;
+ }
+ controller.window.Update(null);
+ return true;
+ }
+}
+
+class MainWindow : Window
+{
+ text = "Keyboard Input Using Controllers";
+ background = black;
+ borderStyle = sizable;
+ hasMaximize = true;
+ hasMinimize = true;
+ hasClose = true;
+ size = { 576, 432 };
+
+ controller = WorldObjectController { this };
+
+ bool OnCreate()
+ {
+ selected = objects[1];
+ ((WorldObjectController)controller).controlled = selected;
+ return true;
+ }
+
+ bool OnLoadGraphics()
+ {
+ for(r : gfxResources)
+ AddResource(r);
+ return true;
+ }
+
+ void OnUnloadGraphics()
+ {
+ for(r : gfxResources)
+ RemoveResource(r);
+ }
+
+ void OnDestroy()
+ {
+ controller = null;
+ objects.Free();
+ }
+
+ void OnRedraw(Surface surface)
+ {
+ for(o : objects)
+ o.Render(surface);
+ }
+}
+
+MainWindow mainWindow {};
--- /dev/null
+{
+ "Version" : 0.2,
+ "ModuleName" : "BitmapAudioKB",
+ "Options" : {
+ "Warnings" : "All",
+ "TargetType" : "Executable",
+ "TargetFileName" : "controller",
+ "Libraries" : [
+ "ecere"
+ ],
+ "Console" : true
+ },
+ "Configurations" : [
+ {
+ "Name" : "Debug",
+ "Options" : {
+ "Debug" : true,
+ "Optimization" : "None",
+ "PreprocessorDefinitions" : [
+ "_DEBUG"
+ ]
+ }
+ },
+ {
+ "Name" : "Release",
+ "Options" : {
+ "Debug" : false,
+ "Optimization" : "Speed"
+ }
+ }
+ ],
+ "Files" : [
+ "controller.ec"
+ ],
+ "ResourcesPath" : "",
+ "Resources" : [
+ "../res/archer.png",
+ "../res/castle.png",
+ "../res/dragon.png",
+ "../res/mage.png",
+ "../res/peasant.png"
+ ]
+}
\ No newline at end of file
--- /dev/null
+import "ecere"
+
+BitmapResource peasantGfx { ":peasant.png" };
+BitmapResource dragonGfx { ":dragon.png" };
+BitmapResource mageGfx { ":mage.png" };
+BitmapResource archerGfx { ":archer.png" };
+BitmapResource castleGfx { ":castle.png" };
+
+Array<BitmapResource> gfxResources { [ peasantGfx, dragonGfx, mageGfx, archerGfx, castleGfx ] };
+
+class WorldObject
+{
+ bool selectable;
+ BitmapResource res;
+
+ void Render(Surface surface)
+ {
+ Bitmap bmp = res ? res.bitmap : null;
+ if(bmp)
+ {
+ surface.Blit(bmp, x, y, 0,0, bmp.width, bmp.height);
+ if(this == selected)
+ {
+ surface.foreground = lime;
+ surface.Rectangle(x-1, y-1, x + bmp.width, y + bmp.height);
+ surface.foreground = white;
+ surface.Rectangle(x-2, y-2, x + bmp.width+1, y + bmp.height+1);
+ }
+ }
+ }
+
+public:
+ int x, y;
+}
+
+class Peasant : WorldObject { res = peasantGfx; selectable = true; }
+class Dragon : WorldObject { res = dragonGfx; }
+class Mage : WorldObject { res = mageGfx; selectable = true; }
+class Archer : WorldObject { res = archerGfx; selectable = true; }
+class Castle : WorldObject { res = castleGfx; }
+
+Array<WorldObject> objects
+{ [
+ Castle { 180, 150 },
+ Mage { 50, 50 },
+ Archer { 150, 250 },
+ Peasant { 380, 290 },
+ Peasant { 120, 150 },
+ Dragon { 320, 50 }
+] };
+
+WorldObject selected;
+
+class MainWindow : Window
+{
+ text = "Moving objects around with the keyboard";
+ background = black;
+ borderStyle = sizable;
+ hasMaximize = true;
+ hasMinimize = true;
+ hasClose = true;
+ size = { 576, 432 };
+
+ bool OnCreate()
+ {
+ selected = objects[1];
+ return true;
+ }
+
+ void OnDestroy()
+ {
+ objects.Free();
+ }
+
+ bool OnLoadGraphics()
+ {
+ for(r : gfxResources)
+ AddResource(r);
+ return true;
+ }
+
+ void OnUnloadGraphics()
+ {
+ for(r : gfxResources)
+ RemoveResource(r);
+ }
+
+ void OnRedraw(Surface surface)
+ {
+ for(o : objects)
+ o.Render(surface);
+ }
+
+ bool OnKeyHit(Key key, unichar ch)
+ {
+ if(selected)
+ {
+ switch(key)
+ {
+ case left: selected.x -= 5; break;
+ case right: selected.x += 5; break;
+ case up: selected.y -= 5; break;
+ case down: selected.y += 5; break;
+ case tab:
+ {
+ Iterator<WorldObject> it { objects };
+ it.Find(selected);
+ do
+ {
+ if(!it.Next())
+ it.Next();
+ selected = it.data;
+ } while(!selected.selectable);
+ break;
+ }
+ }
+ Update(null);
+ }
+ return true;
+ }
+}
+
+MainWindow mainWindow {};
--- /dev/null
+{
+ "Version" : 0.2,
+ "ModuleName" : "BitmapAudioKB",
+ "Options" : {
+ "Warnings" : "All",
+ "TargetType" : "Executable",
+ "TargetFileName" : "OnKeyHit",
+ "Libraries" : [
+ "ecere"
+ ],
+ "Console" : true
+ },
+ "Configurations" : [
+ {
+ "Name" : "Debug",
+ "Options" : {
+ "Debug" : true,
+ "Optimization" : "None",
+ "PreprocessorDefinitions" : [
+ "_DEBUG"
+ ]
+ }
+ },
+ {
+ "Name" : "Release",
+ "Options" : {
+ "Debug" : false,
+ "Optimization" : "Speed"
+ }
+ }
+ ],
+ "Files" : [
+ "OnKeyHit.ec"
+ ],
+ "ResourcesPath" : "",
+ "Resources" : [
+ "../res/archer.png",
+ "../res/castle.png",
+ "../res/dragon.png",
+ "../res/mage.png",
+ "../res/peasant.png"
+ ]
+}
\ No newline at end of file
--- /dev/null
+import "ecere"
+
+BitmapResource peasantGfx { ":peasant.png" };
+BitmapResource dragonGfx { ":dragon.png" };
+BitmapResource mageGfx { ":mage.png" };
+BitmapResource archerGfx { ":archer.png" };
+BitmapResource castleGfx { ":castle.png" };
+
+Array<BitmapResource> gfxResources { [ peasantGfx, dragonGfx, mageGfx, archerGfx, castleGfx ] };
+
+class WorldObject
+{
+ bool selectable;
+ BitmapResource res;
+
+ void Render(Surface surface)
+ {
+ Bitmap bmp = res ? res.bitmap : null;
+ if(bmp)
+ {
+ surface.Blit(bmp, x, y, 0,0, bmp.width, bmp.height);
+ if(this == selected)
+ {
+ surface.foreground = lime;
+ surface.Rectangle(x-1, y-1, x + bmp.width, y + bmp.height);
+ surface.foreground = white;
+ surface.Rectangle(x-2, y-2, x + bmp.width+1, y + bmp.height+1);
+ }
+ }
+ }
+
+public:
+ int x, y;
+}
+
+class Peasant : WorldObject { res = peasantGfx; selectable = true; }
+class Dragon : WorldObject { res = dragonGfx; }
+class Mage : WorldObject { res = mageGfx; selectable = true; }
+class Archer : WorldObject { res = archerGfx; selectable = true; }
+class Castle : WorldObject { res = castleGfx; }
+
+Array<WorldObject> objects
+{ [
+ Castle { 180, 150 },
+ Mage { 50, 50 },
+ Archer { 150, 250 },
+ Peasant { 380, 290 },
+ Peasant { 120, 150 },
+ Dragon { 320, 50 }
+] };
+
+WorldObject selected;
+
+class MainWindow : Window
+{
+ text = "State based keyboard input";
+ background = black;
+ borderStyle = sizable;
+ hasMaximize = true;
+ hasMinimize = true;
+ hasClose = true;
+ size = { 576, 432 };
+
+ bool OnCreate()
+ {
+ selected = objects[1];
+ return true;
+ }
+
+ bool OnLoadGraphics()
+ {
+ for(r : gfxResources)
+ AddResource(r);
+ return true;
+ }
+
+ void OnUnloadGraphics()
+ {
+ for(r : gfxResources)
+ RemoveResource(r);
+ }
+
+ void OnDestroy()
+ {
+ objects.Free();
+ }
+
+ void OnRedraw(Surface surface)
+ {
+ for(o : objects)
+ o.Render(surface);
+ }
+
+ bool OnKeyHit(Key key, unichar ch)
+ {
+ if(selected)
+ {
+ switch(key)
+ {
+ case tab:
+ {
+ Iterator<WorldObject> it { objects };
+ it.Find(selected);
+ do
+ {
+ if(!it.Next())
+ it.Next();
+ selected = it.data;
+ } while(!selected.selectable);
+ Update(null);
+ break;
+ }
+ }
+ Update(null);
+ }
+ return true;
+ }
+}
+
+define moveSpeed = 100.0; // 100 pixels per seconds
+
+class SampleApp : GuiApplication
+{
+ timerResolution = 60;
+ bool Cycle(bool idle)
+ {
+ bool moved = false;
+ static Time lastTime;
+ Time time = GetTime(), diffTime = time - lastTime;
+ if(diffTime >= 1 / moveSpeed)
+ {
+ if(selected)
+ {
+ if(GetKeyState(left)) { selected.x -= diffTime * 100 - 0.5; moved = true; }
+ if(GetKeyState(right)) { selected.x += diffTime * 100; moved = true; }
+ if(GetKeyState(up)) { selected.y -= diffTime * 100 - 0.5; moved = true; }
+ if(GetKeyState(down)) { selected.y += diffTime * 100; moved = true; }
+ if(moved)
+ mainWindow.Update(null);
+ }
+ lastTime = time;
+ }
+ return !moved;
+ }
+}
+
+MainWindow mainWindow {};
--- /dev/null
+{
+ "Version" : 0.2,
+ "ModuleName" : "BitmapAudioKB",
+ "Options" : {
+ "Warnings" : "All",
+ "TargetType" : "Executable",
+ "TargetFileName" : "KBState",
+ "Libraries" : [
+ "ecere"
+ ],
+ "Console" : true
+ },
+ "Configurations" : [
+ {
+ "Name" : "Debug",
+ "Options" : {
+ "Debug" : true,
+ "Optimization" : "None",
+ "PreprocessorDefinitions" : [
+ "_DEBUG"
+ ]
+ }
+ },
+ {
+ "Name" : "Release",
+ "Options" : {
+ "Debug" : false,
+ "Optimization" : "Speed"
+ }
+ }
+ ],
+ "Files" : [
+ "KBState.ec"
+ ],
+ "ResourcesPath" : "",
+ "Resources" : [
+ "../res/archer.png",
+ "../res/castle.png",
+ "../res/dragon.png",
+ "../res/mage.png",
+ "../res/peasant.png"
+ ]
+}
\ No newline at end of file
--- /dev/null
+import "ecere"
+
+BitmapResource peasantGfx { ":peasant.png" };
+BitmapResource dragonGfx { ":dragon.png" };
+BitmapResource mageGfx { ":mage.png" };
+BitmapResource archerGfx { ":archer.png" };
+BitmapResource castleGfx { ":castle.png" };
+
+Array<BitmapResource> gfxResources { [ peasantGfx, dragonGfx, mageGfx, archerGfx, castleGfx ] };
+
+class WorldObject
+{
+ BitmapResource res;
+
+ void Render(Surface surface)
+ {
+ Bitmap bmp = res ? res.bitmap : null;
+ if(bmp)
+ surface.Blit(bmp, x, y, 0,0, bmp.width, bmp.height);
+ }
+
+public:
+ int x, y;
+}
+
+class Peasant : WorldObject { res = peasantGfx; }
+class Dragon : WorldObject { res = dragonGfx; }
+class Mage : WorldObject { res = mageGfx; }
+class Archer : WorldObject { res = archerGfx; }
+class Castle : WorldObject { res = castleGfx; }
+
+Array<WorldObject> objects
+{ [
+ Castle { 180, 150 },
+ Mage { 50, 50 },
+ Archer { 150, 250 },
+ Peasant { 380, 290 },
+ Peasant { 120, 150 },
+ Dragon { 320, 50 }
+] };
+
+class MainWindow : Window
+{
+ text = "A World of Objects";
+ background = black;
+ borderStyle = sizable;
+ hasMaximize = true;
+ hasMinimize = true;
+ hasClose = true;
+ size = { 576, 432 };
+
+ bool OnLoadGraphics()
+ {
+ for(r : gfxResources)
+ AddResource(r);
+ return true;
+ }
+
+ void OnUnloadGraphics()
+ {
+ for(r : gfxResources)
+ RemoveResource(r);
+ }
+
+ void OnDestroy()
+ {
+ objects.Free();
+ }
+
+ void OnRedraw(Surface surface)
+ {
+ for(o : objects)
+ o.Render(surface);
+ }
+}
+
+MainWindow mainWindow {};
--- /dev/null
+{
+ "Version" : 0.2,
+ "ModuleName" : "BitmapAudioKB",
+ "Options" : {
+ "Warnings" : "All",
+ "TargetType" : "Executable",
+ "TargetFileName" : "objects",
+ "Libraries" : [
+ "ecere"
+ ],
+ "Console" : true
+ },
+ "Configurations" : [
+ {
+ "Name" : "Debug",
+ "Options" : {
+ "Debug" : true,
+ "Optimization" : "None",
+ "PreprocessorDefinitions" : [
+ "_DEBUG"
+ ]
+ }
+ },
+ {
+ "Name" : "Release",
+ "Options" : {
+ "Debug" : false,
+ "Optimization" : "Speed"
+ }
+ }
+ ],
+ "Files" : [
+ "objects.ec"
+ ],
+ "ResourcesPath" : "",
+ "Resources" : [
+ "../res/archer.png",
+ "../res/castle.png",
+ "../res/dragon.png",
+ "../res/mage.png",
+ "../res/peasant.png"
+ ]
+}
\ No newline at end of file