[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Gluon] 73b59e5: Add "Ball", an example game by MichaÅ KoźmiÅski
From: Arjen Hiemstra <ahiemstra () heimr ! nl>
Date: 2011-01-04 1:39:53
Message-ID: 20110104013953.ECC9AA6090 () git ! kde ! org
[Download RAW message or body]
A player/examples/ball/ball.gluon [License: Trivialfile.]
A player/examples/ball/Scenes/ball_game.gdl [License: Trivialfile.]
A player/examples/ball/README [License: Trivialfile.]
A player/examples/ball/Assets/ball_trap.js [License: Trivialfile.]
A player/examples/ball/Assets/ball_player.js [License: Trivialfile.]
A player/examples/ball/Assets/ball_controller.js [License: Trivialfile.]
A player/examples/ball/Assets/Ball_Assets_Material.gml [License: UNKNOWN]
commit 73b59e58446b4a39f2a46645c18b83d8cb9bbc09
Author: Arjen Hiemstra <ahiemstra@heimr.nl>
Date: Tue Jan 4 02:15:49 2011 +0100
Add "Ball", an example game by Michał Koźmiński
diff --git a/player/examples/ball/.swp.README b/player/examples/ball/.swp.README
new file mode 100644
index 0000000..f80dde3
Binary files /dev/null and b/player/examples/ball/.swp.README differ
diff --git a/player/examples/ball/Assets/Ball_Assets_Material.gml \
b/player/examples/ball/Assets/Ball_Assets_Material.gml new file mode 100644
index 0000000..c84d6bb
--- /dev/null
+++ b/player/examples/ball/Assets/Ball_Assets_Material.gml
@@ -0,0 +1,44 @@
+{ GluonCore::GluonObject(Material)
+ languageVersion string(1.20)
+
+ vertexShader string(<<<#version 120
+
+uniform mat4 modelViewProj;
+
+attribute vec3 vertex;
+attribute vec4 color;
+attribute vec2 uv0;
+
+varying vec4 out_color;
+varying vec2 out_uv0;
+
+void main()
+{
+ gl_Position = vec4(vertex, 1.0) * modelViewProj;
+ out_color = color;
+ out_uv0 = uv0;
+}
+<<<)
+
+ fragmentShader string(<<<#version 120
+
+uniform sampler2D texture0;
+uniform vec4 materialColor;
+
+varying vec4 out_color;
+varying vec2 out_uv0;
+
+void main()
+{
+ vec4 texColor = texture2D(texture0, out_uv0);
+ vec4 color = out_color * materialColor * texColor;
+ color = vec4(color.r, color.g, color.b, texColor.a * materialColor.a);
+ if(color.a <= 0.0)
+ discard;
+ gl_FragColor = color;
+}
+<<<)
+
+ texture0 int(0)
+ materialColor color(255;255;255;255)
+}
\ No newline at end of file
diff --git a/player/examples/ball/Assets/background.png \
b/player/examples/ball/Assets/background.png new file mode 100644
index 0000000..7640a64
Binary files /dev/null and b/player/examples/ball/Assets/background.png differ
diff --git a/player/examples/ball/Assets/ball.png \
b/player/examples/ball/Assets/ball.png new file mode 100644
index 0000000..a318fd9
Binary files /dev/null and b/player/examples/ball/Assets/ball.png differ
diff --git a/player/examples/ball/Assets/ball_controller.js \
b/player/examples/ball/Assets/ball_controller.js new file mode 100644
index 0000000..bc7c7e2
--- /dev/null
+++ b/player/examples/ball/Assets/ball_controller.js
@@ -0,0 +1,70 @@
+var gMiniumBreakInt = 50;
+var gCurrentlyBreakInt = 0;
+var gPlayerReference = null;
+var gLastScoreUpdateInt = 0;
+var gEndedGameBool = false;
+var gTrapReference = null;
+var gStarReference = null;
+function initialize(){
+ Component.paused = false;
+}
+function start(){
+ Game.score = 0;
+ Game.end = false;
+
+ gTrapReference = Game.getFromScene("Trap");
+ gStarReference = Game.getFromScene("Star");
+ gPlayerReference = Game.clone(Game.getFromScene("Player"));
+ gPlayerReference.setPosition(-25, -40);
+ gPlayerReference.enabled = true;
+}
+
+function update(time){
+ if(Game.end == false){
+ this.deployTrap();
+ if(Game.score%6 ==0 && Game.score != gLastScoreUpdateInt){
+ this.updateScore(Game.score/6);
+ }
+ }else{
+ if(gEndedGameBool==false){
+ this.end();
+ }
+ if(this.GameObject.Key_Reset.isActionHeld()){
+ this.resetGame();
+ }
+ }
+
+
+}
+function deployTrap(){
+ gCurrentlyBreakInt++;
+ if(gCurrentlyBreakInt >=gMiniumBreakInt){
+ if(Math.random()*11 > 9){
+ var trap = Game.clone(gTrapReference);
+ trap.setPosition(50,-40);
+ trap.enabled = true;
+ gCurrentlyBreakInt =0;
+ }
+ }
+
+}
+function updateScore(score){
+ gLastScoreUpdateInt =score*6;
+ var star =Game.clone(gStarReference);
+ star.setPosition(((score%6)*8)-20,Math.floor(score/6)*8);
+ star.enabled=true;
+
+}
+function end(){
+ gEndedGameBool = true;
+ var score =Game.clone(Game.getFromScene("ScoreText"));
+ score.setPosition(-30,0);
+ score.enabled = true;
+ var resetText =Game.clone(Game.getFromScene("ResetText"));
+ resetText.setPosition(-5,-10);
+ resetText.enabled = true;
+
+}
+function resetGame(){
+ Game.resetCurrentScene();
+}
\ No newline at end of file
diff --git a/player/examples/ball/Assets/ball_merry_go.ogg \
b/player/examples/ball/Assets/ball_merry_go.ogg new file mode 100644
index 0000000..3fc984c
Binary files /dev/null and b/player/examples/ball/Assets/ball_merry_go.ogg differ
diff --git a/player/examples/ball/Assets/ball_player.js \
b/player/examples/ball/Assets/ball_player.js new file mode 100644
index 0000000..d5dc596
--- /dev/null
+++ b/player/examples/ball/Assets/ball_player.js
@@ -0,0 +1,35 @@
+var gMaxFrameJumpInt = 25;
+var gCurrentlyFrameJumpInt=0
+var gJumpingBool = false;
+function initialize() {
+}
+function update(time) {
+ this.rotate();
+ this.jump();
+}
+function draw(){
+}
+function rotate(time){
+ this.GameObject.rotate(-2.5,new QVector3D(0,0,1));
+}
+function jump(){
+ if(this.GameObject.Key_Jump.isActionHeld()){
+ gJumpingBool = true;
+ }
+ if(gJumpingBool == true){
+ if(gCurrentlyFrameJumpInt <= gMaxFrameJumpInt){
+ this.GameObject.setPosition(this.GameObject.position.x(),this.GameObject.position.y()+0.7);
+ }
+ if(gCurrentlyFrameJumpInt > gMaxFrameJumpInt){
+ this.GameObject.setPosition(this.GameObject.position.x(),this.GameObject.position.y()-0.7);
+ }
+ if(gCurrentlyFrameJumpInt >= gMaxFrameJumpInt*2){
+ gJumpingBool = false;
+ gCurrentlyFrameJumpInt=0
+ }
+ gCurrentlyFrameJumpInt++;
+ }
+}
+function partOfFrame(time){
+ return time/1000*25;
+}
\ No newline at end of file
diff --git a/player/examples/ball/Assets/ball_trap.js \
b/player/examples/ball/Assets/ball_trap.js new file mode 100644
index 0000000..73bfea7
--- /dev/null
+++ b/player/examples/ball/Assets/ball_trap.js
@@ -0,0 +1,16 @@
+function initialize() {
+}
+
+function update(time){
+ this.GameObject.setPosition(this.GameObject.position.x()-0.5,this.GameObject.position.y());
+ if(this.GameObject.Collider.isColliding()){
+ this.GameObject.destroy();
+ Game.end = true;
+ }
+ if(this.GameObject.position.x() < -50){
+ Game.score += 1;
+ this.GameObject.destroy();
+ }
+}
+function draw(){
+}
diff --git a/player/examples/ball/Assets/reset.png \
b/player/examples/ball/Assets/reset.png new file mode 100644
index 0000000..9a833d7
Binary files /dev/null and b/player/examples/ball/Assets/reset.png differ
diff --git a/player/examples/ball/Assets/score.png \
b/player/examples/ball/Assets/score.png new file mode 100644
index 0000000..a339c72
Binary files /dev/null and b/player/examples/ball/Assets/score.png differ
diff --git a/player/examples/ball/Assets/star.png \
b/player/examples/ball/Assets/star.png new file mode 100644
index 0000000..5f990ea
Binary files /dev/null and b/player/examples/ball/Assets/star.png differ
diff --git a/player/examples/ball/Assets/trap.png \
b/player/examples/ball/Assets/trap.png new file mode 100644
index 0000000..a5cd27a
Binary files /dev/null and b/player/examples/ball/Assets/trap.png differ
diff --git a/player/examples/ball/README b/player/examples/ball/README
new file mode 100644
index 0000000..f3b5c64
--- /dev/null
+++ b/player/examples/ball/README
@@ -0,0 +1,11 @@
+Ball game example for Gluon.
+Controls: Use space to jump.
+
+Created by Michał Koźmiński
+E-mail:michal.kozminski@gmail.com
+
+Graphics used in this project:
+trap.png : CC0 License http://opengameart.org/content/wooden-crate
+ball.png : CC0 License and CC-BY-SA 3.0 http://opengameart.org/content/apples
+star.png : CC0 License http://opengameart.org/content/fabulous-stars
+And some graphics was from Invaders game example for gluon
\ No newline at end of file
diff --git a/player/examples/ball/Scenes/ball_game.gdl \
b/player/examples/ball/Scenes/ball_game.gdl new file mode 100644
index 0000000..e88c6d2
--- /dev/null
+++ b/player/examples/ball/Scenes/ball_game.gdl
@@ -0,0 +1,137 @@
+{ GluonEngine::GameObject(Game)
+ enabled bool(true)
+ position vector3d(0;0;0)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ { GluonEngine::GameObject(Camera)
+ enabled bool(true)
+ position vector3d(0;0;50)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ { GluonEngine::CameraControllerComponent(GluonObject)
+ enabled bool(true)
+ active bool(true)
+ visibleArea size2d(90;90)
+ nearPlane float(1)
+ farPlane float(99.99)
+ }
+ }
+ { GluonEngine::GameObject(Background)
+ enabled bool(true)
+ position vector3d(0;0;0)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ psition vector3d(0;0;0)
+ { GluonEngine::SpriteRendererComponent(GluonObject)
+ enabled bool(true)
+ size size2d(633;480)
+ material \
GluonGraphics::MaterialInstance(Ball/Assets/Material/Background) + color \
rgba(255;255;255;255) + }
+ { GluonEngine::QtScriptComponent(ControllerScript)
+ enabled bool(true)
+ script GluonEngine::Asset(Ball/Assets/Scripts/controller.js)
+ paused bool(false)
+ }
+ { GluonEngine::KeyboardInputComponent(Key_Reset)
+ enabled bool(true)
+ keyCode int(57)
+ }
+ { GluonEngine::SoundListenerComponent(SoundListenerComponent)
+ enabled bool(true)
+ active bool(true)
+ effectsEnabled bool(true)
+ }
+ { GluonEngine::SoundEmitterComponent(SoundEmitterComponent)
+ enabled bool(true)
+ sound GluonEngine::Asset(Ball/merry_go.ogg)
+ radius float(99.99)
+ volume float(1)
+ pitch float(1)
+ loop bool(true)
+ autoPlay bool(true)
+ }
+ }
+ { GluonEngine::GameObject(Player)
+ enabled bool(false)
+ position vector3d(100;0;1)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ { GluonEngine::SpriteRendererComponent(SpriteRenderer)
+ enabled bool(true)
+ size size2d(8;8)
+ material GluonGraphics::MaterialInstance(Ball/Assets/Material/Ball)
+ color rgba(255;255;255;255)
+ }
+ { GluonEngine::KeyboardInputComponent(Key_Jump)
+ enabled bool(true)
+ keyCode int(57)
+ }
+ { GluonEngine::QtScriptComponent(GluonObject)
+ enabled bool(true)
+ script GluonEngine::Asset(Ball/Assets/Scripts/player.js)
+ }
+ { GluonEngine::SphereCollisionComponent(TrapCollider)
+ enabled bool(true)
+ collisionGroup int(1)
+ radius float(8)
+ }
+ }
+ { GluonEngine::GameObject(Trap)
+ enabled bool(false)
+ position vector3d(100;0;1)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ { GluonEngine::SpriteRendererComponent(GluonObject)
+ enabled bool(true)
+ size size2d(8;8)
+ material GluonGraphics::MaterialInstance(Ball/Assets/Material/Trap)
+ color rgba(255;255;255;255)
+ }
+ { GluonEngine::QtScriptComponent(Script)
+ enabled bool(true)
+ script GluonEngine::Asset(Ball/Assets/Scripts/trap.js)
+ }
+ { GluonEngine::SphereCollisionComponent(Collider)
+ enabled bool(true)
+ collisionGroup int(1)
+ radius float(8)
+ }
+ }
+ { GluonEngine::GameObject(Star)
+ enabled bool(false)
+ position vector3d(100;0;1)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ { GluonEngine::SpriteRendererComponent(GluonObject)
+ enabled bool(true)
+ size size2d(8;8)
+ material GluonGraphics::MaterialInstance(Ball/Assets/Material/Star)
+ color rgba(255;255;255;255)
+ }
+ }
+ { GluonEngine::GameObject(ScoreText)
+ enabled bool(false)
+ position vector3d(100;0;1)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ { GluonEngine::SpriteRendererComponent(GluonObject)
+ enabled bool(true)
+ size size2d(30;9)
+ material GluonGraphics::MaterialInstance(Ball/Assets/Material/Score)
+ color rgba(255;255;255;255)
+ }
+ }
+ { GluonEngine::GameObject(ResetText)
+ enabled bool(false)
+ position vector3d(100;0;1)
+ scale vector3d(1;1;1)
+ orientation quaternion(0;0;0;1)
+ { GluonEngine::SpriteRendererComponent(GluonObject)
+ enabled bool(true)
+ size size2d(30;9)
+ material GluonGraphics::MaterialInstance(Ball/Assets/Material/Reset)
+ color rgba(255;255;255;255)
+ }
+ }
+}
\ No newline at end of file
diff --git a/player/examples/ball/ball.gluon b/player/examples/ball/ball.gluon
new file mode 100644
index 0000000..bb567b8
--- /dev/null
+++ b/player/examples/ball/ball.gluon
@@ -0,0 +1,75 @@
+{ GluonEngine::GameProject(Ball)
+ description string(Ball Game)
+ entryPoint GluonEngine::Scene(Ball/Scenes/Game)
+ id string(271210)
+ { GluonCore::GluonObject(Scenes)
+ { GluonEngine::Scene(Game)
+ file url(Scenes/ball_game.gdl)
+ }
+ }
+ { GluonCore::GluonObject(Assets)
+ { GluonCore::GluonObject(Scripts)
+ { GluonEngine::ScriptAsset(controller.js)
+ file url(Assets/ball_controller.js)
+ }
+ { GluonEngine::ScriptAsset(player.js)
+ file url(Assets/ball_player.js)
+ }
+ { GluonEngine::ScriptAsset(trap.js)
+ file url(Assets/ball_trap.js)
+ }
+ }
+ { GluonCore::GluonObject(Textures)
+ { GluonEngine::TextureAsset(background.png)
+ file url(Assets/background.png)
+ }
+ { GluonEngine::TextureAsset(ball.png)
+ file url(Assets/ball.png)
+ }
+ { GluonEngine::TextureAsset(score.png)
+ file url(Assets/score.png)
+ }
+ { GluonEngine::TextureAsset(star.png)
+ file url(Assets/star.png)
+ }
+ { GluonEngine::TextureAsset(reset.png)
+ file url(Assets/reset.png)
+ }
+ { GluonEngine::TextureAsset(trap.png)
+ file url(Assets/trap.png)
+ }
+ }
+ { GluonEngine::MaterialAsset(Material)
+ file url(Assets/Ball_Assets_Material.gml)
+ { GluonGraphics::MaterialInstance(Background)
+ materialColor rgba(255;255;255;255)
+ texture0 string(background.png)
+ }
+ { GluonGraphics::MaterialInstance(Ball)
+ materialColor rgba(255;255;255;255)
+ texture0 string(ball.png)
+ }
+ { GluonGraphics::MaterialInstance(Score)
+ materialColor rgba(255;255;255;255)
+ texture0 string(score.png)
+ }
+ { GluonGraphics::MaterialInstance(Star)
+ materialColor rgba(255;255;255;255)
+ texture0 string(star.png)
+ }
+ { GluonGraphics::MaterialInstance(Reset)
+ materialColor rgba(255;255;255;255)
+ texture0 string(reset.png)
+ }
+ { GluonGraphics::MaterialInstance(Trap)
+ materialColor rgba(255;255;255;255)
+ texture0 string(trap.png)
+ }
+ }
+ }
+ { GluonCore::GluonObject(Prefabs)
+ }
+ { GluonEngine::SoundAsset(merry_go.ogg)
+ file url(Assets/ball_merry_go.ogg)
+ }
+}
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic