If I ever wrote an Ogre/NxOgre/OIS/Audio wrapper framework..

betajaen

25-09-2006 18:53:33

...a typical application would look like this:

#include <Karma.h>
using namespace Karma;

needs(KarmaApplication);

class Application : public KarmaApplication {

KarmaApplicationPrerequisites;

void start() {

Scene("Main")->hasGravityAndFloor();
Scene("Main")->from("cube.mdl")->create("myCube", at(0,4,0));
Audio::Play("gameMusic.mp3", Audio::LoopForever);

Event::Observe(
Keyboard(Keyboard::EscapeKey),
Keyboard::OnPress,
Karma::Quit
);

Event::MultiObserve(
Keyboard(Keyboard::WASD_Keys),
Mouse(Mouse::OnMovement),
Camera("Main"),
Camera::MoveAndLookAt
);

Event::MultiObserve(
Keyboard("IKJLUM"),
Keyboard::OnPress,
Mdl("myCube")::addForce,
Arguments<Directional(XxYyZz), Force(10)>
);

Event::Observe(
Mdl("myCube"),
Mdl::Y,
Condition(MoreThan(10.0f)),
CreateOverlay(
"WinningText",
"FadeText",
"Well done you've won the game!"
at(Karma::Overlays::CenterX, Karma::Overlays::CenterY),
options(
"startOpacity: 100
"endOpacity: 0",
"fadeTime: 5",
"autoDelete: yes",
"duplicates: no"
);
);
);

Karma::CreateOverlay(
"FPS",
"Text"
at(10,10),
size(50,12)
);

Karma::Watch(this);
}

void end() {

}

void watched(Frame &frame) {
Overlay("FPS")->set(frame.FPS + " FPS");
}

}


Equivalent to Tutorial101 with music, and checks if the cube has reached 10 meters in height if yes then a text overlay "You win" is shown and faded out for 2 seconds.

I am thinking of writing it. Once 0.5 is released.

DaCracker

25-09-2006 18:55:35

Looks really good! :D

BlasterN

26-09-2006 11:29:58

Event::MultiObserve(
Keyboard("IKJLUM"),
Keyboard::OnPress,
Mdl("myCube")::addForce,
Arguments<Directional(XxYyZz), Force(10)>
);


REALLY SMART!!! maybe mixed with enable/disable gravity and we have a easy editor ^^
nice work beatjean.

betajaen

26-09-2006 12:33:02

You nearly spelled my name completely wrong there ;)

Anyway; An Editor would be certainly possible with this sort of framework but I was aiming for anything to made from it from simple utilities to full blown games.

As for your gravity idea:

Event::Observe(
Keyboard(Keyboard::G_Key),
Keyboard::OnPress,
Scene("Main"),
Scene::hasGravity()
);

ahmadi

04-10-2006 09:23:57

oh expressive class, :D Thanks betajaen.
What is your audio engine?

betajaen

04-10-2006 10:12:48

OpenAL I assume.