Sorry if my code is terrible, first time i try to use AGK:
// Project: Heads or Tails
// Created: 2016-12-22
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Heads or Tails" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution(1080, 1920)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
UseNewDefaultFonts( 1 ) // since version 2.0.20 we can use nicer default fonts
CreateSprite(1, 0)
//Heads to Heads: 1-17
for i = 1 to 17
LoadImage(i, "Heads to Heads\" + Str(i) + ".png")
SetImageMinFilter(i, 0)
SetImageMagFilter(i, 0)
AddSpriteAnimationFrame(1, i)
next i
//Heads to Tails: 18-29
for i = 18 to 29
LoadImage(i, "Heads to Tails\" + Str(i) + ".png")
SetImageMinFilter(i, 0)
SetImageMagFilter(i, 0)
AddSpriteAnimationFrame(1, i)
next i
//Tails to Heads: 30-38
for i = 30 to 38
LoadImage(i, "Tails to Heads\" + Str(i) + ".png")
SetImageMinFilter(i, 0)
SetImageMagFilter(i, 0)
AddSpriteAnimationFrame(1, i)
next i
//Tails to Tails: 39-47
for i = 39 to 47
LoadImage(i, "Tails to Tails\" + Str(i) + ".png")
SetImageMinFilter(i, 0)
SetImageMagFilter(i, 0)
AddSpriteAnimationFrame(1, i)
next i
SetSpriteSize(1, 400, 400)
SetSpriteOffset(1, 200, 200)
SetSpritePositionByOffset(1, 1080/2, 1920/2)
AddVirtualButton(1, 1080/2,1920/2 + 500, 400)
SetVirtualButtonText(1, "Heads or Tails")
//SetSpritePosition(1, 1080/2, 1920/2)
//PlaySprite(1, 10, 1, 1, 8)
//0-Heads 1-Tails
coin_state = 0
curr = 0
do
If GetVirtualButtonPressed(1) = 1
curr = Random(0,1)
if curr = 0 and coin_state = 0
PlaySprite(1,10,0,1,17)
coin_state = 0
elseif curr = 0 and coin_state = 1
PlaySprite(1,10,0,18,29)
coin_state = 1
elseif curr = 1 and coin_state = 0
PlaySprite(1,10,0,30,38)
coin_state = 0
elseif curr = 1 and coin_state = 1
PlaySprite(1,10,0,39,47)
coin_state = 1
endif
endif
Sync()
loop
So, the loops at the start set each frame to the sprite. I attached the pictures in this thread if you guys need them(They are terrible, i just quickly made them with photoshop to try making this app :p )
Inside the main loop, i think its pretty self explanatory. If the button is pressed, play the specific animation needed.
My problem is, it always comes out to Heads for some reason. What am i doing wrong?
Sorry for the noob question :p
Trololololo