Hello
Been thinking of creating a sliding games bonanza which is a compendium full of sliding games of sort...
It will be based on a cube with each face having a different game to play
The cube can be rotated around to play each game
Game 1
Beat 2048
// Project: 2048 3D
// Created: 2020-03-07
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "2048 3D" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // 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
type _colours
r,g,b,a
t
endtype
colours as _colours
type _images
number
img
endtype
global images as _images[]
type _tiles
objid
number
img
imgid
bounce
scl#
endtype
global tiles as _tiles[32,32,32]
global gridsize,depth
tilesize = 5
gridsize = 4
setupimages(tilesize)
// make a frame
frame = CreateObjectBox((tilesize) * gridsize + 5,(tilesize) * gridsize + 5,(tilesize) * gridsize + 5)
//cleartiles
for x=0 to gridsize-1
for y=0 to gridsize-1
for z=0 to gridsize-1
tiles[x,y,z].number = 0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
next
next
next
for a=0 to 7
addtiles()
next
SetCameraPosition(1,0,gridsize*8,-gridsize*16)
x = 0 : y = 0 : z = 0
// calculate the very centre of the whole cubex
gs# = (tilesize * gridsize) / 2.0 - tilesize/2
//SetObjectVisible(frame,0)
for x=0 to gridsize-1
for y=0 to gridsize-1
tiles[x,y,z].objid = CreateObjectBox(tilesize,tilesize,.5)
SetObjectPosition(tiles[x,y,z].objid,-gs#+x * (tilesize), gs#-y * (tilesize), -(tilesize) * gridsize + 5)
if tiles[x,y,z].number<>0
SetObjectImage(tiles[x,y,z].objid, tiles[x,y,z].img, 1)
tiles[x,y,z].scl# = .1
tiles[x,y,z].bounce=1
else
SetObjectColor(tiles[x,y,z].objid,255,255,255,10)
SetObjectTransparency(tiles[x,y,z].objid,1)
endif
FixObjectToObject(tiles[x,y,z].objid,frame)
// endif
next
next
shiftxtimes=0
do
print(GetRawLastKey())
if GetRawKeyState(65) then RotateObjectLocalY(frame,1)
if GetRawKeyState(68) then RotateObjectLocalY(frame,-1)
if GetRawKeyState(87) then RotateObjectLocalX(frame,1)
if GetRawKeyState(83) then RotateObjectLocalX(frame,-1)
if GetRawKeyPressed(37) then shiftx=-1
if GetRawKeyPressed(39) then shiftx=1
if GetRawKeyPressed(38) then shifty=-1
if GetRawKeyPressed(40) then shifty=1
if shifty=-1
didwemoveornot=0
repeat
nomoremoves=0
for x=0 to gridsize-1
for y=1 to gridsize-1
for z=0 to depth
if tiles[x,y,z].number<>0 and tiles[x,y-1,z].number=0
tiles[x,y-1,z].number = tiles[x,y,z].number
tiles[x,y-1,z].img = tiles[x,y,z].img
tiles[x,y-1,z].imgid = tiles[x,y,z].imgid
tiles[x,y-1,z].scl# = 1
tiles[x,y-1,z].bounce=0
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
inc didwemoveornot
nomoremoves=1
else
// combine
if tiles[x,y-1,z].number = tiles[x,y,z].number and tiles[x,y-1,z].number<>0
tiles[x,y-1,z].number = tiles[x,y-1,z].number * 2
inc tiles[x,y-1,z].imgid
tiles[x,y-1,z].img = images[tiles[x,y-1,z].imgid].img
tiles[x,y-1,z].bounce=1
tiles[x,y-1,z].scl#=.1
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
tiles[x,y,z].bounce=0
tiles[x,y,z].scl#=.1
endif
inc didwemoveornot
endif
next
next
next
until nomoremoves=0
if didwemoveornot>0 then addtiles()
shifty=0
endif
if shifty=1
didwemoveornot=0
repeat
nomoremoves=0
for x=0 to gridsize-1
for y=0 to gridsize-2
for z=0 to depth
if tiles[x,y,z].number<>0 and tiles[x,y+1,z].number=0
tiles[x,y+1,z].number = tiles[x,y,z].number
tiles[x,y+1,z].img = tiles[x,y,z].img
tiles[x,y+1,z].imgid = tiles[x,y,z].imgid
tiles[x,y+1,z].scl# = 1
tiles[x,y+1,z].bounce=0
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
inc didwemoveornot
nomoremoves=1
else
// combine
if tiles[x,y+1,z].number = tiles[x,y,z].number and tiles[x,y+1,z].number<>0
tiles[x,y+1,z].number = tiles[x,y+1,z].number * 2
inc tiles[x,y+1,z].imgid
tiles[x,y+1,z].img = images[tiles[x,y+1,z].imgid].img
tiles[x,y+1,z].bounce=1
tiles[x,y+1,z].scl#=.1
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
tiles[x,y,z].bounce=0
tiles[x,y,z].scl#=.1
endif
inc didwemoveornot
endif
next
next
next
until nomoremoves=0
if didwemoveornot>0 then addtiles()
shifty=0
endif
if shiftx=-1
didwemoveornot=0
repeat
nomoremoves=0
for x=1 to gridsize-1
for y=0 to gridsize-1
for z=0 to depth
if tiles[x,y,z].number<>0 and tiles[x-1,y,z].number=0
tiles[x-1,y,z].number = tiles[x,y,z].number
tiles[x-1,y,z].img = tiles[x,y,z].img
tiles[x-1,y,z].imgid = tiles[x,y,z].imgid
tiles[x-1,y,z].scl# = 1
tiles[x-1,y,z].bounce=0
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
nomoremoves=1
inc didwemoveornot
else
// combine
if tiles[x-1,y,z].number = tiles[x,y,z].number and tiles[x-1,y,z].number<>0
tiles[x-1,y,z].number = tiles[x-1,y,z].number * 2
inc tiles[x-1,y,z].imgid
tiles[x-1,y,z].img = images[tiles[x-1,y,z].imgid].img
tiles[x-1,y,z].bounce=1
tiles[x-1,y,z].scl#=.1
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
tiles[x,y,z].bounce=0
tiles[x,y,z].scl#=.1
endif
inc didwemoveornot
endif
next
next
next
until nomoremoves=0
if didwemoveornot>0 then addtiles()
shiftx=0
endif
if shiftx=1
didwemoveornot=0
repeat
nomoremoves=0
for x=0 to gridsize-2
for y=0 to gridsize-1
for z=0 to depth
if tiles[x,y,z].number<>0 and tiles[x+1,y,z].number=0
tiles[x+1,y,z].number = tiles[x,y,z].number
tiles[x+1,y,z].img = tiles[x,y,z].img
tiles[x+1,y,z].imgid = tiles[x,y,z].imgid
tiles[x+1,y,z].scl# = 1
tiles[x+1,y,z].bounce=0
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
nomoremoves=1
inc didwemoveornot
else
// combine
if tiles[x+1,y,z].number = tiles[x,y,z].number and tiles[x+1,y,z].number<>0
tiles[x+1,y,z].number = tiles[x+1,y,z].number * 2
inc tiles[x+1,y,z].imgid
tiles[x+1,y,z].img = images[tiles[x+1,y,z].imgid].img
tiles[x+1,y,z].bounce=1
tiles[x+1,y,z].scl#=.1
tiles[x,y,z].number=0
tiles[x,y,z].img = 0
tiles[x,y,z].imgid = -1
tiles[x,y,z].bounce=0
tiles[x,y,z].scl#=1
endif
inc didwemoveornot
endif
next
next
next
until nomoremoves=0
if didwemoveornot>0 then addtiles()
shiftx=0
endif
// repaint the images
for x=0 to gridsize-1
for y=0 to gridsize-1
for z=0 to depth
if tiles[x,y,z].number<>0
SetObjectImage(tiles[x,y,z].objid, tiles[x,y,z].img, 1)
SetObjectTransparency(tiles[x,y,z].objid,0)
SetObjectScale(tiles[x,y,z].objid,tiles[x,y,z].scl#,tiles[x,y,z].scl#,tiles[x,y,z].scl#)
inc tiles[x,y,z].scl#,.1
if tiles[x,y,z].scl#>=1
tiles[x,y,z].scl#=1
tiles[x,y,z].bounce=0
endif
else
SetObjectColor(tiles[x,y,z].objid,255,255,255,2)
SetObjectTransparency(tiles[x,y,z].objid,1)
endif
next
next
next
Print( ScreenFPS() )
Sync()
loop
function addtiles()
//addtiles
repeat
tilefound=0
tnx = random(0,gridsize-1)
tny = random(0,gridsize-1)
tnz = random(0,depth)
if tiles[tnx,tny,tnz].number = 0
number2or4 = random(0,100)
if number2or4<75
tiles[tnx,tny,tnz].number = 2
tiles[tnx,tny,tnz].imgid = 0
tiles[tnx,tny,tnz].img = images[tiles[tnx,tny,tnz].imgid].img
else
tiles[tnx,tny,tnz].number = 2
tiles[tnx,tny,tnz].imgid = 0
tiles[tnx,tny,tnz].img = images[tiles[tnx,tny,tnz].imgid].img
endif
tiles[tnx,tny,tnz].bounce=1
tiles[tnx,tny,tnz].scl#=.1
tilefound=1
endif
until tilefound=1
endfunction
function setupimages(tilesize)
image as _images
image.number = 2 : image.img = createnumberimages(2,tilesize) : images.insert(image)
image.number = 4 : image.img = createnumberimages(4,tilesize) : images.insert(image)
image.number = 8 : image.img = createnumberimages(8,tilesize) : images.insert(image)
image.number = 16 : image.img = createnumberimages(16,tilesize) : images.insert(image)
image.number = 32 : image.img = createnumberimages(32,tilesize) : images.insert(image)
image.number = 64 : image.img = createnumberimages(64,tilesize) : images.insert(image)
image.number = 128 : image.img = createnumberimages(128,tilesize) : images.insert(image)
image.number = 256 : image.img = createnumberimages(256,tilesize) : images.insert(image)
image.number = 512 : image.img = createnumberimages(512,tilesize) : images.insert(image)
image.number = 1024 : image.img = createnumberimages(1024,tilesize) : images.insert(image)
image.number = 2048 : image.img = createnumberimages(2048,tilesize) : images.insert(image)
endfunction
function createnumberimages(number,tilesize)
rgb as _colours
t=CreateText(str(number))
SetTextSize(t,(tilesize * 16)/tilesize)
SetTextColor(t,0,0,0,255)
swap()
ClearScreen()
for x=0 to 32
for y=0 to 32
rgb=Get2048Color(number)
r=random2(0,0)
if rgb.r+r>255 then rgb.r=255
if rgb.g+r>255 then rgb.g=255
if rgb.b+r>255 then rgb.b=255
c=MakeColor(rgb.r+r, rgb.g + r, rgb.b + r)
DrawBox(x,y,x+1,y+1,c,c,c,c,1)
next
next
SetTextPosition(t,16-GetTextTotalWidth(t)/2,16-GetTextTotalHeight(t)/2)
Render2DFront()
render()
img = GetImage(0,0,32,32)
DeleteText(t)
endfunction img
function Get2048Color(number)
colour as _colours
if number=2 or number=4
colour.r = 119
colour.g = 110
colour.b = 101
endif
if number=8
colour.r=242
colour.g=177
colour.g=121
endif
if number=16
colour.r=245
colour.g=149
colour.b=99
endif
if number=32
colour.r = 246
colour.g = 124
colour.b = 95
endif
if number=64
colour.r = 246
colour.g = 94
colour.b = 59
endif
if number=128
colour.r = 237
colour.g = 207
colour.b = 114
endif
if number=256
colour.r = 237
colour.g = 207
colour.b = 97
endif
if number=512
colour.r = 237
colour.g = 200
colour.b = 80
endif
if number=1024
colour.r = 237
colour.g = 197
colour.b = 63
endif
if number=2048
colour.r = 237
colour.g = 194
colour.b = 46
endif
if number=2048
colour.r = 0
colour.g = 0
colour.b = 0
endif
endfunction colour
Game 2 on a different face
Move the tiles to make sure the numbers are in numerical order.
// Project: 2048 3D
// Created: 2020-03-07
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "2048 3D" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // 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
type _colours
r,g,b,a
t
endtype
colours as _colours
type _images
number
img
endtype
global images as _images[]
type _tiles
objid
number
img
imgid
bounce
scl#
emptyspace
endtype
global tiles as _tiles[32,32,32]
global gridsize,depth
tilesize = 5
gridsize = 4
frameimg = createframeimage()
setupimages(tilesize)
// make a frame
frame = CreateObjectBox((tilesize+1) * gridsize + 5,(tilesize+1) * gridsize + 5,(tilesize/2))
SetObjectImage(frame,frameimg,1)
//cleartiles
num=1
for x=0 to gridsize-1
for y=0 to gridsize-1
tiles[x,y,z].number = num
tiles[x,y,z].imgid = num-1
tiles[x,y,z].img = images[num-1].img
inc num
next
next
maxnums=num
SetCameraPosition(1,0,gridsize*5,-gridsize*10)
x = 0 : y = 0 : z = 0
// calculate the very centre of the whole cubex
gs# = ((tilesize+1) * gridsize) / 2.0 - (tilesize+1)/2
timesmoved=0
num=1
for x=0 to gridsize-1
for y=0 to gridsize-1
tiles[x,y,z].objid = CreateObjectBox(tilesize,tilesize,.5)
tiles[x,y,z].number = tiles[x,y,z].objid
SetObjectPosition(tiles[x,y,z].objid,-gs#+(x * (tilesize+1)), gs#-(y * (tilesize+1)), -tilesize/3)
if tiles[x,y,z].number<>0
SetObjectImage(tiles[x,y,z].objid, tiles[x,y,z].img, 1)
tiles[x,y,z].scl# = .1
tiles[x,y,z].bounce=1
else
SetObjectColor(tiles[x,y,z].objid,255,255,255,10)
SetObjectTransparency(tiles[x,y,z].objid,1)
endif
FixObjectToObject(tiles[x,y,z].objid,frame)
if num>=maxnums-1
emptyspacex=x
emptyspacey=y
tiles[x,y,z].emptyspace=1
SetObjectVisible(tiles[x,y,z].objid,0)
else
tiles[x,y,z].emptyspace=0
SetObjectVisible(tiles[x,y,z].objid,1)
endif
inc num
next
next
do
print(GetRawLastKey())
if GetRawKeyState(65) then RotateObjectLocalY(frame,1)
if GetRawKeyState(68) then RotateObjectLocalY(frame,-1)
if GetRawKeyState(87) then RotateObjectLocalX(frame,1)
if GetRawKeyState(83) then RotateObjectLocalX(frame,-1)
if GetRawKeyPressed(37) then shiftx=-1
if GetRawKeyPressed(39) then shiftx=1
if GetRawKeyPressed(38) then shifty=-1
if GetRawKeyPressed(40) then shifty=1
print(emptyspacex)
print(emptyspacey)
if shifty=1 // DOWN
//which column
col = emptyspacey
for x=0 to gridsize-1
for y=1 to gridsize-1
if x=emptyspacex and y=emptyspacey
inc timesmoved
if timesmoved<=tilesize+1
// SetObjectPosition(tiles[x,y-1,z].objid,getobjectx(tiles[x,y-1,z].objid),getobjecty(tiles[x,y-1,z].objid)-1,getobjectz(tiles[x,y-1,z].objid))
else
tiles[x,y,z].objid = tiles[x,y-1,z].objid
tiles[x,y,z].emptyspace = 0
tiles[x,y-1,z].emptyspace=1
tiles[x,y,z].number = tiles[x,y-1,z].number
emptyspacex=x
emptyspacey=y-1
timesmoved=0
shifty=0
endif
endif
next
next
endif
if shifty=-1 // DOWN
//which column
col = emptyspacey
for x=0 to gridsize-1
for y=0 to gridsize-2
if x=emptyspacex and y=emptyspacey
inc timesmoved
if timesmoved<=tilesize+1
// SetObjectPosition(tiles[x,y+1,z].objid,getobjectx(tiles[x,y+1,z].objid),getobjecty(tiles[x,y+1,z].objid)+1,getobjectz(tiles[x,y+1,z].objid))
else
tiles[x,y,z].emptyspace = 0
tiles[x,y+1,z].emptyspace=1
tiles[x,y,z].number = tiles[x,y+1,z].number
tiles[x,y,z].objid = tiles[x,y+1,z].objid
emptyspacex=x
emptyspacey=y+1
timesmoved=0
shifty=0
endif
endif
next
next
endif
if shiftx=1 // left
//which row
col = emptyspacey
for x=1 to gridsize-1
for y=0 to gridsize-1
if x=emptyspacex and y=emptyspacey
inc timesmoved
if timesmoved<=tilesize+1
// SetObjectPosition(tiles[x,y+1,z].objid,getobjectx(tiles[x,y+1,z].objid),getobjecty(tiles[x,y+1,z].objid)+1,getobjectz(tiles[x,y+1,z].objid))
else
tiles[x,y,z].emptyspace = 0
tiles[x-1,y,z].emptyspace=1
tiles[x,y,z].number = tiles[x-1,y,z].number
tiles[x,y,z].objid = tiles[x-1,y,z].objid
emptyspacex=x-1
emptyspacey=y
timesmoved=0
shiftx=0
endif
endif
next
next
endif
if shiftx=-1 // right
//which row
col = emptyspacey
for x=0 to gridsize-2
for y=0 to gridsize-1
if x=emptyspacex and y=emptyspacey
inc timesmoved
if timesmoved<=tilesize+1
// SetObjectPosition(tiles[x,y+1,z].objid,getobjectx(tiles[x,y+1,z].objid),getobjecty(tiles[x,y+1,z].objid)+1,getobjectz(tiles[x,y+1,z].objid))
else
tiles[x,y,z].emptyspace = 0
tiles[x+1,y,z].emptyspace=1
tiles[x,y,z].number = tiles[x+1,y,z].number
tiles[x,y,z].objid = tiles[x+1,y,z].objid
emptyspacex=x+1
emptyspacey=y
timesmoved=0
shiftx=0
endif
endif
next
next
endif
//repaint
for y=0 to gridsize-1
for x=0 to gridsize-1
if tiles[x,y,z].emptyspace=0
tiles[x,y,z].objid = tiles[x,y,z].number
SetObjectPosition(tiles[x,y,z].objid,-gs#+(x * (tilesize+1)), gs#-(y * (tilesize+1)), -tilesize/3)
endif
next
next
Print( ScreenFPS() )
Sync()
loop
function setupimages(tilesize)
image as _images
for a=1 to 32
image.number = a : image.img = createnumberimages(a,tilesize) : images.insert(image)
next
endfunction
function createframeimage()
swap()
ClearScreen()
for x=0 to 64
for y=0 to 64
c=MakeColor(random(0,255),random(0,255),random(0,255))
DrawBox(x,y,x+1,y+1,c,c,c,c,1)
next
next
render()
img = GetImage(0,0,64,64)
endfunction img
function createnumberimages(number,tilesize)
t=CreateText(str(number))
SetTextSize(t,(tilesize * 16)/tilesize)
SetTextColor(t,0,0,0,255)
swap()
ClearScreen()
DrawBox(0,0,64,64,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
for x=0 to 64
for y=0 to 64
c=MakeColor(100,200,200)
DrawBox(x,y,x+1,y+1,c,c,c,c,1)
next
next
SetTextPosition(t,32-GetTextTotalWidth(t)/2,32-GetTextTotalHeight(t)/2)
Render2DFront()
render()
img = GetImage(0,0,64,64)
DeleteText(t)
endfunction img
function Get2048Color(number)
colour as _colours
if number=2 or number=4
colour.r = 119
colour.g = 110
colour.b = 101
endif
if number=8
colour.r=242
colour.g=177
colour.g=121
endif
if number=16
colour.r=245
colour.g=149
colour.b=99
endif
if number=32
colour.r = 246
colour.g = 124
colour.b = 95
endif
if number=64
colour.r = 246
colour.g = 94
colour.b = 59
endif
if number=128
colour.r = 237
colour.g = 207
colour.b = 114
endif
if number=256
colour.r = 237
colour.g = 207
colour.b = 97
endif
if number=512
colour.r = 237
colour.g = 200
colour.b = 80
endif
if number=1024
colour.r = 237
colour.g = 197
colour.b = 63
endif
if number=2048
colour.r = 237
colour.g = 194
colour.b = 46
endif
if number=2048
colour.r = 0
colour.g = 0
colour.b = 0
endif
endfunction colour
Still lots to do on each and more games to think about in the future
Be back in a week or 2 for an update
3rd Game on a 3rd Face
Spot the difference
// Project: 2048 3D
// Created: 2020-03-07
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Differences" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // 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
type _colours
r,g,b,a
t
endtype
colours as _colours
type _images
number
img
endtype
global images as _images[]
type _tiles
objid
number
img
imgid
bounce
scl#
emptyspace
endtype
global tiles as _tiles[32,32,32]
global gridsize,depth
tilesize = 5
gridsize = 4
frameimg = createframeimage()
setupimages(tilesize)
// make a frame
frame = CreateObjectBox((tilesize+1) * gridsize + 5,(tilesize+1) * gridsize + 5,(tilesize/2))
SetObjectImage(frame,frameimg,1)
//cleartiles
num=1
for x=0 to gridsize-1
for y=0 to gridsize-1
tiles[x,y,z].number = num
tiles[x,y,z].imgid = num-1
tiles[x,y,z].img = images[num-1].img
inc num
next
next
maxnums=num
SetCameraPosition(1,0,gridsize*5,-gridsize*10)
x = 0 : y = 0 : z = 0
// calculate the very centre of the whole cubex
gs# = ((tilesize+1) * gridsize) / 2.0 - (tilesize+1)/2
timesmoved=0
num=1
for x=0 to gridsize-1
for y=0 to gridsize-1
tiles[x,y,z].objid = CreateObjectBox(tilesize,tilesize,.5)
tiles[x,y,z].number = tiles[x,y,z].objid
SetObjectPosition(tiles[x,y,z].objid,-gs#+(x * (tilesize+1)), gs#-(y * (tilesize+1)), -tilesize/3)
if tiles[x,y,z].number<>0
SetObjectImage(tiles[x,y,z].objid, tiles[x,y,z].img, 1)
tiles[x,y,z].scl# = .1
tiles[x,y,z].bounce=1
else
SetObjectColor(tiles[x,y,z].objid,255,255,255,10)
SetObjectTransparency(tiles[x,y,z].objid,1)
endif
FixObjectToObject(tiles[x,y,z].objid,frame)
SetObjectVisible(tiles[x,y,z].objid,1)
inc num
next
next
startgame=1 : starttimesmoved=0
do
print(GetRawLastKey())
if GetRawKeyState(65) then RotateObjectLocalY(frame,1)
if GetRawKeyState(68) then RotateObjectLocalY(frame,-1)
if GetRawKeyState(87) then RotateObjectLocalX(frame,1)
if GetRawKeyState(83) then RotateObjectLocalX(frame,-1)
if GetRawKeyPressed(37) then shiftx=-1
if GetRawKeyPressed(39) then shiftx=1
if GetRawKeyPressed(38) then shifty=-1
if GetRawKeyPressed(40) then shifty=1
//repaint
for y=0 to gridsize-1
for x=0 to gridsize-1
if tiles[x,y,z].emptyspace=0
tiles[x,y,z].objid = tiles[x,y,z].number
SetObjectPosition(tiles[x,y,z].objid,-gs#+(x * (tilesize+1)), gs#-(y * (tilesize+1)), -tilesize/3)
endif
next
next
Print( ScreenFPS() )
Sync()
// sleep(1000)
loop
function setupimages(tilesize)
image as _images
b=1
for a=1 to 32
image.number = a : image.img = createnumberimages(b,tilesize) : images.insert(image)
if mod(a,2)=0 then inc b
next
endfunction
function createframeimage()
swap()
ClearScreen()
for x=0 to 64
for y=0 to 64
c=MakeColor(random(0,255),random(0,255),random(0,255))
DrawBox(x,y,x+1,y+1,c,c,c,c,1)
next
next
render()
img = GetImage(0,0,64,64)
endfunction img
function createnumberimages(number,tilesize)
t=CreateText(str(number))
SetTextSize(t,(tilesize * 16)/tilesize)
SetTextColor(t,0,0,0,255)
swap()
ClearScreen()
DrawBox(0,0,64,64,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
for x=0 to 64
for y=0 to 64
c=MakeColor(100,200,200)
DrawBox(x,y,x+1,y+1,c,c,c,c,1)
next
next
SetTextPosition(t,32-GetTextTotalWidth(t)/2,32-GetTextTotalHeight(t)/2)
Render2DFront()
render()
img = GetImage(0,0,64,64)
DeleteText(t)
endfunction img
Game #4 on a 4th face
A different sized block puzzle where have to place each piece on the grid to fill the grid up with no gaps
Any other ideas are welcome for further mini games
Best crack on getting coding on the above for the minute though....
Works on the idea like this
// Project: SlidingBonanza
// Created: 2020-03-08
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "SlidingBonanza" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // 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
gridsize#=3
tilesize=5
maxsize#=(gridsize#*tilesize * 2) + (gridsize#*3)
frame = CreateObjectBox(maxsize#,maxsize#,maxsize#)
SetCameraPosition(1,0,maxsize#*2,-maxsize#*4)
// Game 1 tiles // FRONT
for x#=-gridsize#/2.0 to gridsize#/2.0
for y#=-gridsize#/2.0 to gridsize#/2.0
tile = CreateObjectBox(tilesize,tilesize,1)
SetObjectPosition(tile,x# * (tilesize*2), -y#*(tilesize*2), -maxsize#/2)
SetObjectColor(tile,255,0,0,255)
FixObjectToObject(tile,frame)
next
next
// Game 1 tiles // BACK
for x#=-gridsize#/2.0 to gridsize#/2.0
for y#=-gridsize#/2.0 to gridsize#/2.0
tile = CreateObjectBox(tilesize,tilesize,1)
SetObjectPosition(tile,x# * (tilesize*2), -y#*(tilesize*2), maxsize#/2)
SetObjectColor(tile,0,255,255,255)
FixObjectToObject(tile,frame)
next
next
// Game 2 tiles TOP
for x#=-gridsize#/2.0 to gridsize#/2.0
for z#=-gridsize#/2.0 to gridsize#/2.0
tile = CreateObjectBox(tilesize,1,tilesize)
SetObjectPosition(tile,x# * (tilesize*2), maxsize#/2, -z#*(tilesize*2))
SetObjectColor(tile,0,255,0,255)
FixObjectToObject(tile,frame)
next
next
// Game 3 tiles RIGHT
for y#=-gridsize#/2.0 to gridsize#/2.0
for z#=-gridsize#/2.0 to gridsize#/2.0
tile = CreateObjectBox(1,tilesize,tilesize)
SetObjectPosition(tile,maxsize# /2, y# * (tilesize*2), -z#*(tilesize*2))
SetObjectColor(tile,0,0,255,255)
FixObjectToObject(tile,frame)
next
next
// Game 4 tiles BOTTOM
for x#=-gridsize#/2.0 to gridsize#/2.0
for z#=-gridsize#/2.0 to gridsize#/2.0
tile = CreateObjectBox(tilesize,1,tilesize)
SetObjectPosition(tile,x# * (tilesize*2), -maxsize#/2, z#*(tilesize*2))
SetObjectColor(tile,255,255,0,255)
FixObjectToObject(tile,frame)
next
next
// Game 3 tiles LEFT
for y#=-gridsize#/2.0 to gridsize#/2.0
for z#=-gridsize#/2.0 to gridsize#/2.0
tile = CreateObjectBox(1,tilesize,tilesize)
SetObjectPosition(tile,-maxsize#/2, y# * (tilesize*2), -z#*(tilesize*2))
SetObjectColor(tile,255,0,255,255)
FixObjectToObject(tile,frame)
next
next
do
if GetRawKeyState(37) then RotateObjectLocalY(frame,1)
if GetRawKeyState(39) then RotateObjectLocalY(frame,-1)
if GetRawKeyState(38) then RotateObjectLocalX(frame,1)
if GetRawKeyState(40) then RotateObjectLocalX(frame,-1)
Print( ScreenFPS() )
Sync()
loop
Each face is a game.