Made with AGK²
Download Demo: https://www.dropbox.com/s/8xrvabbo6rbtjdk/Made%20with%20AGK%C2%B2.zip?dl=0
AGK
// Project: Made with AGK²
// Created: 2015-05-01
// set window properties
SetWindowTitle("Made with AGK²")
SetWindowSize( 0, 0, -1 )
DW = GetDeviceWidth()
DH = GetDeviceHeight()
// set display properties
SetVirtualResolution(DW, DH)
SetOrientationAllowed( 0, 0, 1, 1 )
SetSyncRate(60, 1)
SetRandomSeed(1)
SetRandomSeed2(0)
LoadMusic(1, "zarathustra.mp3")
PlayMusic(1)
LoadImage(1, "ground.png")
o = 0
for z = 0 to 40 step 10
for x = 0 to 40 step 10
inc o
CreateObjectPlane(o, 10, 10)
SetObjectRotation(o, 90, 0, 0)
SetObjectPosition(o, x, 0, z)
SetObjectImage(o, 1, 0)
next x
next z
LoadImage(2, "grass.png")
o = 100
CreateObjectPlane(o, 10, 12)
SetObjectImage(o, 2, 0)
SetObjectTransparency(o, 1)
SetObjectPosition(o, 0, 6, 0)
LoadShader(1, "sway.vs", "sway.ps")
SetObjectShader(o, 1)
SetShaderConstantByName(1, "SwayXZ", 2.0, 2.0, 0, 0)
for i = 1 to 400
InstanceObject(o + i, o)
x = Random(0, 40)
z = Random(0, 40)
a = Random2(-90, 90)
SetObjectPosition(o + i, x, 6, z)
SetObjectRotation(o + i, 0, a, 0)
next i
LoadImage(3, "darksky.jpg")
CreateObjectSphere(50, 100, 32, 32)
SetObjectImage(50, 3, 0)
SetObjectCullMode(50, 2)
SetObjectLightMode(50, 0)
SetObjectPosition(50, 20, 10, 20)
LoadImage(4, "alpha.png")
LoadImage(5, "alpha.png")
CreateObjectBox(51, 10, 20, 2)
SetObjectColor(51, 0, 0, 0, 0)
LoadShader(2, "vertex.vs", "alpha.ps")
repeat
a# = a# + 0.05
SetCameraPosition(1, 20, 15 + sin(a# * 5) * 5, -20)
SetCameraLookAt(1, 20, 10, 20, 0)
SetObjectRotation(50, 0, a#, 0)
if 200 - a# > 10 then SetObjectPosition(51, 20, 200 - a#, 20)
if GetMusicPosition() > 75 and t = 0
SetObjectImage(51, 4, 0)
SetObjectImage(51, 4, 1)
SetObjectShader(51, 2)
t = 1
endif
//Print(ScreenFPS())
Sync()
until GetRawKeyPressed(27)
end
Sway Shader
uniform mat4 agk_WorldViewProj;
uniform float agk_time;
uniform vec2 SwayXZ;
attribute vec3 position;
attribute vec2 uv;
varying vec2 uvVarying;
void main()
{
vec2 dir;
vec4 sway;
if(position.y > 0.0)
{
dir.x = SwayXZ.x * sin(agk_time);
dir.y = SwayXZ.y * cos(agk_time);
}
sway.x = position.x + dir.x;
sway.y = position.y;
sway.z = position.z + dir.y;
sway.w = 1.0;
gl_Position = agk_WorldViewProj * sway;
uvVarying = uv;
}
Have fun!