Interesting...simple code that runs fine in AppGameKit is compiling, and running, but not with expected results. Anyone else getting this?
Can anyone test this code? Just copy/paste.
rem
rem AGK Application
rem
rem Landscape App
SetDisplayAspect( 4.0/3.0 )
global parallax_speed as float
parallax_speed = 0.05
type parallax_sprite
x as float
y as float
start_x as float
start_y as float
distance_x as float
distance_y as float
target_x as float
target_y as float
parallax_amount as float
sprite
endtype
dim Sprite[3] as parallax_sprite
for i = 0 to 2
Sprite[i].sprite = createSprite (0)
SetSpriteSize(Sprite[i].sprite, Random(5,35), Random(5,65))
SetSpritePosition (Sprite[i].sprite, Random(1,20), Random(10,90))
Sprite[i].start_x = GetSpriteX(Sprite[i].sprite)
Sprite[i].start_y = GetSpriteY(Sprite[i].sprite)
Sprite[i].parallax_amount = Random(3,5)*0.01
next i
//----------------------------------------------- do loop
do
for i = 0 to 2
if (GetPointerX() < GetVirtualWidth() * 0.5)// or (GetPointerY() < GetVirtualHeight() * 0.5)
Sprite[i].distance_x = GetVirtualWidth() * 0.5 - GetPointerX() //this should give us the distance
Sprite[i].target_x = Sprite[i].start_x + (Sprite[i].distance_x * Sprite[i].parallax_amount) //a target to be pointed at
Sprite[i].distance_y = GetVirtualHeight() * 0.5 - GetPointerY() //this should give us the distance
Sprite[i].target_y = Sprite[i].start_y + (Sprite[i].distance_y * Sprite[i].parallax_amount) //a target to be pointed at
else
Sprite[i].distance_x = GetPointerX() - (GetVirtualWidth() * 0.5)
Sprite[i].target_x = Sprite[i].start_x - (Sprite[i].distance_x * Sprite[i].parallax_amount) //a target to be pointed at
Sprite[i].distance_y = GetPointerY() - GetVirtualHeight() * 0.5
Sprite[i].target_y = Sprite[i].start_y - (Sprite[i].distance_y * Sprite[i].parallax_amount)
endif
Sprite[i].x = Hermite(Sprite[i].x, Sprite[i].target_x, parallax_speed) //use a hermetic lerp or something. Needs to be sped according to it\'s modifier
Sprite[i].y = Hermite(Sprite[i].y, Sprite[i].target_y, parallax_speed)
SetSpritePosition(Sprite[i].sprite, Sprite[i].x, Sprite[i].y)
next i
print(GetPointerX())
print (Sprite[0].distance_x)
print (Sprite[0].distance_y)
Sync()
loop
//-----------------------------------functions
function Hermite( startValue as float, endValue as float, value as float)
result# = Lerp(startValue, endValue, value * value * (3.0 - 2.0 * value))
endfunction result#
function Lerp( startValue as float, endValue as float , value as float )
result# = ((1.0 - value) * startValue) + (value * endValue);
endfunction result#
In AppGameKit, there are three sprites that are on screen, and parallax a little. In FE, the text is there, but the sprites aren't. Odd. Am I missing something simple?
Greenlig
ZacDuff.com