GarBenjamin
Thank you, I am cheeking it out and seeing how it works
I think people forget im new to appgamekit and am learning and this is so I can learn better.
If you want to help then help
if not then that is ok also.
I apprenticeship all the help indeed.
I can post the full code as it is just the same code he provided with my sprites and a couple things I added.
I like your code
My code in full
// show all errors
//SetErrorMode(2)
// set window properties
SetWindowSize( 640, 960, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 640, 960 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
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 ) // since version 2.0.22 we can use nicer default fonts
///////////// M A I N G L O B A L S A N D A R A Y S T A R T ////////////////
global level:level=2
global newsize as integer
global scaleme as integer
global takeaway as integer
global Change_Sprite as integer
global turnoff as integer
global switch as integer
global trigger as integer
global Not_Selected_Style as integer
global Selected_Style as integer
global time_to_delete as integer:time_to_delete=0
global delete_timmer as integer:delete_timmer=0
global Turns:Turns=25
#constant MARGIN_LEFT 40
#constant MARGIN_TOP 240
#constant BOARD_SIZE 7
#constant CELL_SIZE 70
#constant QTY_STYLES 9
#constant HORIZONTAL 0
#constant VERTICAL 1
type tCell
style as integer
spr as integer
txt as integer[2]
qtyMatches as integer[1]
checked as integer[1]
playme as integer
falling as integer
name as String
endtype
type sprites
playme as integer
Selected as integer
Selected_2 as integer
playtime as integer
falldown
endtype
dim all_sprites[200000] as sprites
global board as tCell[BOARD_SIZE, BOARD_SIZE]
global image as integer[QTY_STYLES]
// LOAD ALL IMAGES FOR PETS
image[0] = loadimage("images/Lizard.png")
image[1] = loadimage("images/Octopus.png")
image[2] = loadimage("images/owl.png")
image[3] = loadimage("images/pig.png")
image[4] = loadimage("images/rabbit.png")
image[5] = loadimage("images/rcat.png")
image[6] = loadimage("images/sheep.png")
image[7] = loadimage("images/spider.png")
image[8] = loadimage("images/unucow.png")
image[9] = loadimage("images/cat.png")
// LOAD IN ALL IMAGES FOR BACKGROUND
loadimage(9,"images/background-1.png")
createsprite(1,9)
loadimage(10,"images/dialog-panel.png")
createsprite(2,10)
SetSpritePosition(2,-15,160)
SetSpriteSize(2,670,550)
SetSpriteScale(2,1,1.3)
loadimage(11,"images/status-panel.png")
createsprite(3,11)
SetSpritePosition(3,10,20)
loadimage(12,"images/progress-bar.png")
createsprite(4,12)
SetSpritePosition(4,140,93)
LoadImage(13,"images/output.png")
LoadImage(14,"images/button-menu.png")
createsprite(5,14)
SetSpritePosition(5,220,850)
LoadImage(15,"images/arrow-next.png")
createsprite(6,15)
SetSpritePosition(6,420,850)
LoadImage(16,"images/arrow-back.png")
createsprite(7,16)
SetSpritePosition(7,100,850)
rem create all text before loop
CreateText ( 100, "x=" )
SetTextPosition ( 100,150,900)
SetTextSize ( 100, 30 )
FixTextToScreen ( 100, 1 )
SetTextColorAlpha ( 100, 255 )
line1$ = "x=" + str (x# )
SetTextString ( 100, line1$ )
SetTextVisible(100,0)
CreateText ( 200, "y=" )
SetTextPosition ( 200,350,900)
SetTextSize ( 200, 30 )
FixTextToScreen ( 200, 1 )
SetTextColorAlpha ( 200, 255 )
line1$ = "y=" + str (y# )
SetTextString ( 200, line1$ )
SetTextVisible(200,0)
CreateText ( 201, "" )
SetTextPosition ( 201,60,85)
SetTextSize ( 201, 60 )
FixTextToScreen ( 201, 1 )
SetTextColorAlpha ( 201, 255 )
line1$ = "" + str (level )
SetTextString ( 201, line1$ )
SetTextFontImage(201,13)
CreateText ( 202, "" )
SetTextPosition ( 202,517,85)
SetTextSize ( 202, 55 )
FixTextToScreen ( 202, 1 )
SetTextColorAlpha ( 202, 255 )
line1$ = "" + str (turns )
SetTextString ( 202, line1$ )
SetTextFontImage(202,13)
CreateText ( 1000 ,"SECONDS=" )
SetTextPosition ( 1000 ,300,850)
SetTextSize ( 1000, 35 )
FixTextToScreen ( 1000, 1 )
SetTextColorAlpha ( 1000, 255 )
SetTextFontImage(1000,13)
SetTextVisible(1000,0)
line2$ = "SECONDS=" + str (seconds )
SetTextString ( 1000, line2$ )
CreateText ( 1001 ,"MINUTES=" )
SetTextPosition ( 1001 ,60,850)
SetTextSize ( 1001, 35 )
FixTextToScreen ( 1001, 1 )
SetTextColorAlpha ( 1001, 255 )
SetTextFontImage(1001,13)
SetTextVisible(1001,0)
line3$ = "MINUTES=" + str (min )
SetTextString ( 1001, line3$ )
//set progress-bar for decresing with time
timex=GetSpriteWidth(4)
timey=GetSpriteHeight(4)
//set up game bord before loop
InitialiseBoard()
GetMatches()
ShowMatches()
///////////// M A I N L O O P S T A R T ////////////////
repeat
//ShowBenchmarking()
if GetRawKeyPressed(46) or GetRawMouseRightPressed()
RandomiseBoard()
GetMatches()
endif
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
Pressed=GetPointerPressed()
Released=GetPointerReleased()
if GetSpriteExists(board[x,y].spr)=1
if GetspriteHitTest( board[x,y].spr, x#, y# ) =1
PlaySprite(board[x,y].spr,15,0)
ImageID=GetSpriteImageID(board[x,y].spr)
Print("The Image Style is "+Str( all_sprites[board[x,y].spr].Falldown,0))
endif
if GetRawKeyPressed(32) or GetPointerPressed()
all_sprites[board[x,y].spr].playme=0
endif
if GetspriteHitTest( board[x,y].spr, x#, y# ) =1 and trigger=0 and pressed=1
Selected_Style=board[x,y].style
all_sprites[board[x,y].spr].Selected=1
trigger=1
endif
if GetspriteHitTest( board[x,y].spr, x#, y# ) =1 and all_sprites[board[x,y].spr].Selected=0 and trigger=1 and pressed=1
Not_Selected_Style=board[x,y].style
all_sprites[board[x,y].spr].Selected_2=1
switch=1
endif
if switch=1 and all_sprites[board[x,y].spr].Selected=1
board[x,y].style=Not_Selected_Style
SetSpriteImage(board[x,y].spr, image[board[x,y].style])
switch=2
all_sprites[board[x,y].spr].Selected=0
endif
if switch=2 and all_sprites[board[x,y].spr].Selected_2=1
board[x,y].style=Selected_Style
SetSpriteImage(board[x,y].spr, image[board[x,y].style])
turnoff=1
dec turns,1
all_sprites[board[x,y].spr].Selected_2=0
endif
if turnoff=1
switch=0
delete_timmer=1
trigger=0
turnoff=0
endif
if delete_timmer=1
time_to_delete=time_to_delete+1
endif
if time_to_delete=300
GetMatches()
DeleteMatches()
Falldown()
delete_timmer=0
time_to_delete=0
endif
fally=GetSpriteY(board[x,y].spr)
fallx=GetSpritex(board[x,y].spr)
if all_sprites[board[x,y].spr].Falldown=1
SetSpritePosition(board[x,y].spr,fallx,fally+falling)
falling=falling+1
SetSpriteDepth(board[x,y].spr,0)
endif
if fally>=705
all_sprites[board[x,y].spr].Falldown=0
falling=0
fally=600
endif
ImageID=GetSpriteImageID(board[x,y].spr)
if board[x,y].style=0 then frames=8
if board[x,y].style=1 then frames=9
if board[x,y].style=2 then frames=13
if board[x,y].style=3 then frames=13
if board[x,y].style=4 then frames=13
if board[x,y].style=5 then frames=5
if board[x,y].style=6 then frames=13
if board[x,y].style=7 then frames=12
if board[x,y].style=8 then frames=13
if board[x,y].style=9 then frames=13
SetSpriteAnimation(board[x,y].spr,675,601,frames)
endif
next x
next y
x# = GetPointerX ( )
y# = GetPointerY ( )
line1$ = "x=" + str (x# )
SetTextString ( 100, line1$ )
line1$ = "y=" + str (y# )
SetTextString ( 200, line1$ )
line1$ = "" + str (level )
SetTextString ( 201, line1$ )
line1$ = "" + str (turns )
SetTextString ( 202, line1$ )
line2$ = "SECONDS=" + str (seconds )
SetTextString ( 1000, line2$ )
line3$ = "MINUTES=" + str (min )
SetTextString ( 1001, line3$ )
SetSpriteSize(4,timex-initialTime-10,timey)
time# = 305-timer()
min = floor(time#/60)
seconds = mod(time#,60)
milli# = fmod(time#,1)
initialTime = GetSeconds ( )
Sync()
until GetRawKeyPressed(27)
end
///////////// M A I N L O O P E N D ////////////////
///////////// M A I N F U N C T I O N S S T A R T ////////////////
function Falldown()
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
//Horizontal
falling = board[x,y].spr
if GetSpriteExists(board[x,y].spr)=1
for k = 0 to falling
all_sprites[board[x,y].spr].Falldown=1
next k
endif
//Vertical
falling = board[x,y].spr
if GetSpriteExists(board[x,y].spr)=1
for k = 0 to falling
all_sprites[board[x,y].spr].Falldown=1
next k
endif
next x
next y
endfunction
function DeleteMatches()
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
//Horizontal
matches = board[x,y].qtyMatches[HORIZONTAL]
if matches >= 3 and GetSpriteExists(board[x,y].spr)=1
for k = 0 to matches-1
DeleteSprite(board[x+k,y].spr)
next k
endif
//Vertical
matches = board[x,y].qtyMatches[VERTICAL]
if matches >= 3 and GetSpriteExists(board[x,y].spr)=1
for k = 0 to matches-1
DeleteSprite(board[x,y+k].spr)
next k
endif
next x
next y
endfunction
function GetMatches()
ClearMatches()
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
for k = 0 to 1
if board[x,y].checked[k] = 0
match = CheckMatches(k, x,y)
if match > board[x,y].qtyMatches[k]
board[x,y].qtyMatches[k] = match
endif
endif
next k
next x
next y
endfunction
function CheckMatches(k, x, y)
match = 1
if k = HORIZONTAL
while x < BOARD_SIZE
if board[x,y].style = board[x+1,y].style
board[x,y].checked[k] = 1
inc match
inc x
else
exitfunction match
endif
endwhile
exitfunction match
else
while y < BOARD_SIZE
if board[x,y].style = board[x,y+1].style
board[x,y].checked[k] = 1
inc match
inc y
else
exitfunction match
endif
endwhile
endif
endfunction match
function ClearMatches()
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
for k = 0 to 1
board[x,y].qtyMatches[k] = 1
board[x,y].checked[k] = 0
next k
next x
next y
endfunction
function ShowMatches()
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
for k = 0 to 1
SetTextString(board[x,y].txt[k], str(board[x,y].qtyMatches[k]))
SetTextVisible(board[x,y].txt[k], board[x,y].qtyMatches[k] >= 300)
next k
next x
next y
endfunction
function InitialiseBoard()
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
board[x,y].spr = CreateSprite(0)
SetSpriteSize(board[x,y].spr, CELL_SIZE+10, CELL_SIZE+10)
SetSpritePosition(board[x,y].spr, MARGIN_LEFT + x*CELL_SIZE-8, MARGIN_TOP + y*CELL_SIZE-9)
SetSpriteUVBorder( board[x,y].spr, 2 )
SetSpriteImage ( board[x,y].spr, 10)
board[x,y].spr = CreateSprite(0)
SetSpriteSize(board[x,y].spr, CELL_SIZE+9, CELL_SIZE+9)
SetSpritePosition(board[x,y].spr, MARGIN_LEFT + x*CELL_SIZE+1, MARGIN_TOP + y*CELL_SIZE+1)
SetSpriteUVBorder( board[x,y].spr, 2 )
setspritescale(board[x,y].spr,0.8,0.8)
SetSpriteColor(board[x,y].spr,160,82,45,255)
SetSortCreated(1)
board[x,y].spr = CreateSprite(0)
SetSpriteSize(board[x,y].spr, CELL_SIZE, CELL_SIZE)
setspritescale(board[x,y].spr,0.9,0.9)
SetSpritePosition(board[x,y].spr, MARGIN_LEFT + x*CELL_SIZE, MARGIN_TOP + y*CELL_SIZE)
SetSpriteUVBorder( board[x,y].spr, 2 )
for k = 0 to 1
board[x,y].txt[k] = CreateText("0")
SetTextColor(board[x,y].txt[k], 255, 255, 255, 255)
SetTextSize(board[x,y].txt[k], CELL_SIZE/1.5)
SetTextBold(board[x,y].txt[k], 1)
next k
SetTextPosition(board[x,y].txt[0], MARGIN_LEFT + x*CELL_SIZE + CELL_SIZE/4, MARGIN_TOP + y*CELL_SIZE + CELL_SIZE/5)
SetTextPosition(board[x,y].txt[1], MARGIN_LEFT + x*CELL_SIZE + CELL_SIZE/2, MARGIN_TOP + y*CELL_SIZE + CELL_SIZE/5)
SetTextColor(board[x,y].txt[0], 64, 128, 224, 255)
SetTextColor(board[x,y].txt[1], 64, 224, 64, 255)
next x
next y
RandomiseBoard()
endfunction
function RandomiseBoard()
for y = 0 to BOARD_SIZE
for x = 0 to BOARD_SIZE
if x=0 then setx=0
if x=1 then setx=1
if x=2 then setx=2
if x=3 then setx=3
if x=4 then setx=4
if x=5 then setx=5
if x=6 then setx=6
if x=7 then setx=7
if y=0 then sety=5
if y=1 then sety=4
if y=2 then sety=3
if y=3 then sety=2
if y=4 then sety=1
if y=5 then sety=4
if y=6 then sety=3
if y=7 then sety=2
set=set
board[x,y].style = Random(setx, sety)
if GetSpriteExists(board[x,y].spr)=1 then SetSpriteImage(board[x,y].spr, image[board[x,y].style])
//if GetSpriteExists(board[x,y].spr)=1 then SetSpriteVisible(board[x,y].spr, 1)
if set>=8 then set=0
next x
next y
endfunction
function LinearInterpolate( y1 as float, y2 as float, mu as float)
local f as float
f=(y1*(1.0-mu)+y2*mu)
endfunction f
function ShowBenchmarking()
print ("FPS "+str(screenfps()))
print ("Drawing Setup Time "+str(GetDrawingSetupTime()))
print ("Drawing Time "+str(GetDrawingTime()))
print ("Pixels Drawn "+str(GetPixelsDrawn()))
print ("Update Time "+str(GetUpdateTime()))
print ("Physics Time "+str(GetPhysicsTime()))
print ("Managed Sprite Count "+str(GetManagedSpriteCount()))
print ("Managed Sprite Draw Calls "+str(GetManagedSpriteDrawCalls()))
print ("Managed Sprite Drawn Count "+str(GetManagedSpriteDrawnCount()))
print ("Managed Sprite Sorted Count "+str(GetManagedSpriteSortedCount()))
print ("Particle Drawn Point Count "+str(GetParticleDrawnPointCount()))
print ("Particle Drawn Quad Count "+str(GetParticleDrawnQuadCount()))
print ("Loaded Images "+str(GetLoadedImages()))
UnassignedImages=GetUnassignedImages()
print ("Unassigned Images "+str(UnassignedImages))
for i=1 to UnassignedImages
print ("Unassigned Image FileName "+GetUnassignedImageFileName(i))
next
endfunction
///////////// M A I N F U N C T I O N S E N D ////////////////