Hi,
after seeing 3D wallpapers on my phone.
I wanted to make one...
Too bad AppGameKit can't generate wallpaper.
for our telephone/tablet
but here is a first try, note that I hadn't coded in AppGameKit for a long time.
the principle:
we create 3 PNG images, one for the background (image3 in the code)
another one for the characters, it will be the image2, it will be central.
and finally an image "image1" which will be the foreground ...
then we just have to create 3 objects on which we will draw our images.
two of which will be transparent...
we pose and animate a camera, and here's the result:
Translated with www.DeepL.com/Translator (free version)
Video:
you can download the archive here :
http://michel.dobro.free.fr/AGK/parallax.zip
le code : have Fun
// Project: parallax
// Created: 20-01-27
// By Dobro
// show all errors
SetErrorMode(2)
SetGlobal3DDepth( 500 )
SetAmbientColor( 255, 255, 255 )
// set window properties
SetWindowTitle( "parallax" )
SetWindowSize( 800, 1024, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 800, 1024 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 0, 0 ) // allow both portrait
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
// on charge les images
im1=LoadImage("san_go_ku/1.png")
im2=LoadImage("san_go_ku/2.png")
im3=LoadImage("san_go_ku/3.png")
// creation des objets cube pour l'affichage des images
CreateObjectBox( 1, 800, 1024, 1)
CreateObjectBox( 2, 800, 1024, 1 )
CreateObjectBox( 3, 800, 1024, 1)
// on attribut les images sur les cubes (textures)
SetObjectImage( 1, im1, 1)
SetObjectImage( 2, im2,1 )
SetObjectImage( 3, im3,1 )
camera=1
// defini un point de depart , le premier cube sera a 600 "pas" de la camera
start_position= 600
SetAmbientColor( 10,10,10 )
// on postionne chaque cube l'un devant l'autre comme des Calcques
SetObjectPosition(3, 0, 0, start_position )
SetObjectPosition(2, 0, 0, start_position-50 )
SetObjectPosition(1, 0, 0, start_position-100)
// on force la camera a regarder nos objets
SetCameraLookAt( Camera, 0,0,0,0 )
// tres important , on rend les calcques 1 et 2 transparent.... le 3 est le calque de fond ("calque" = objet)
SetObjectTransparency( 2, 1 )
SetObjectTransparency( 1, 1 )
//defini la vitesse d'animation
vitesse#=8
do
//angle#=GetDirectionAngle() // <--- ceci pourrai servir a recuperer l'angle du telephone ou de la tablette
// pour faire changer l'animation en fonction de l'inclinaison
depl#=depl#+vitesse#
SetCameraLookAt( camera, 0,0, 800, 0 )
rr#=sin(depl#)*100
//MoveCameralocalx( camera, rr#)
SetCameraPosition( camera, rr#, 0, 0 )
// on affiche nos calques
DrawObject( 3 )
DrawObject( 2 )
DrawObject( 1 )
// *** pour debuggage *****
// SetPrintSize(80)
// Print(rr#)
// *************************
sync() // on affiche
loop
Carpe Diem