betajaen
25-09-2006 18:53:33
...a typical application would look like this:
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.
#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.