Posted: 2nd Sep 2018 17:50
Thought you might like me to add this to the collection

+ Code Snippet
// Project: MeshTemplate
// Created: 2018-09-02

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "Mesh Template" )
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
global ang#, angx#, angy#, fDiffY#, startx#, starty#, camerax#,cameray#,cameraz#,memblock, numberofcubes, inventorycubecount

Type Vertex
	
	x as float
	y as float
	z as float
	nx as float
	ny as float
	nz as float
	u as float
	v as float
	color as integer
endtype

Type Triangle
	v1 as integer
	v2 as integer
	v3 as integer
endtype

Type Mesh
	VertexList as Vertex[]
	TriangleList as Triangle[]
endtype

global MeshID as Mesh

size#=5
bladesize#=.2
heaviness#=1 // higher the more fuller

// Heavy Grass
y#=0
for x#=0 to size# step bladesize#
	for z#=0 to size# step bladesize#
		CreateMeshObjectGrassBladeWithColor(x#,0,z#,bladesize#,random2(0,heaviness#),MakeColor(0,random(100-50,100),0))
	next
next
object = CreateObjectFromMeshWithColor(MeshID)

grass as integer[]
i=0
for wx#=-20 to 20
	for wz#=-20 to 20
		grass.insert(InstanceObject(object))
		SetObjectPosition(grass[i],wx# * size#, 0, wz# * size#)
		inc i
	next
next
do
//	RotateObjectLocalX(object,1)
//	RotateObjectLocalY(object,1)
//	RotateObjectLocalZ(object,1)
	
	movecamerawithmouse()
    Print( ScreenFPS() )
    Sync()
loop


function movecamerawithmouse()
       
    fDiffX# = (GetPointerX() - startx#)/4.0
    fDiffY# = (GetPointerY() - starty#)/4.0
   
    newX# = angx# + fDiffY#
    if ( newX# > 360 ) then newX# = 360
    if ( newX# < -360 ) then newX# = -360
     
    // if we keep hold of the left mouse button then rotate the view otherwise the camera stays put
    // so can concentrate on adding/removing blocks at that positon
     
     
    SetCameraRotation( 1, newX#, angy# + fDiffX#, 0 )
   
endfunction

function CreateMeshObjectGrassBladeWithColor(x#, y#, z#, Width#, Height#, Color)
	
	top=random(-1,1)  // add a movement
	AddVertex(MeshID, x#				,y#					,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#/2+top		,y#+height#		,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#			,y#					,z#			, 0,1,0, 0,0,Color)

	AddVertex(MeshID, x#				,y#					,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#			,y#					,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#/2+top		,y#+height#+top			,z#			, 0,1,0, 0,0,Color)

	AddVertex(MeshID, x#+width#/2+top		,y#					,z#-width#/2+top			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#/2+top		,y#					,z#+width#/2+top			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#/2+top		,y#+height#+top			,z#			, 0,1,0, 0,0,Color)
	
	AddVertex(MeshID, x#+width#/2+top		,y#					,z#-width#/2+top			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#/2+top		,y#+height#+top		,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#/2+top		,y#					,z#+width#/2+top			, 0,1,0, 0,0,Color)


endfunction MeshID


function CreateMeshObjectBoxWithColor(x#, y#, z#, Width#, Height#, Depth#, Color)
	
//Front Face	
	AddVertex(MeshID, x#			,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#			, 0,1,0, 0,0,Color)	

// Left
	AddVertex(MeshID, x#			,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#			,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#+height#	,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#			,z#-depth#		, 0,1,0, 0,0,Color)

// Right
	AddVertex(MeshID, x#+width#		,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#			,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#			,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#-depth#	, 0,1,0, 0,0,Color)
	
//back
	AddVertex(MeshID, x#			,y#			,z#-depth#, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#+height#	,z#-depth#, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#-depth#, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#			,z#-depth#, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#-depth#, 0,1,0, 0,0,Color)	
	AddVertex(MeshID, x#+width#		,y#			,z#-depth#, 0,1,0, 0,0,Color)

//top
	AddVertex(MeshID, x#			,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#			,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#			,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#			,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#			,z#-depth#	, 0,1,0, 0,0,Color)

// bottom
	AddVertex(MeshID, x#			,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#+height#	,z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#+width#		,y#+height#	,z#-depth#	, 0,1,0, 0,0,Color)
	AddVertex(MeshID, x#			,y#+height#	,z#-depth#	, 0,1,0, 0,0,Color)
	



endfunction MeshID

function addcube(meshID ref as mesh, cubesize#, tilenumberx, tilenumbery, normx#,normy#,normz#,x#,y#,z#)

// calculate the UVs  - YIKES here we go
	cubex#=((tilenumberx-1) * .5) + tilenumberx // 
	cubey#=(tilenumbery * 0.5)+ 0.5
	maxx# = ((100/15.00)/100) * cubex#
	minx# = (maxx#-(100/15.00)/100)
	halfx# = (maxx#/2 + minx# / 2) 
	bottommaxx# = ((100/15.00)/100) * (cubex#+.5)
	bottomminx# = (bottommaxx#-((100/15.00)/100))
	bottomhalfx# = (bottommaxx#/2 + bottomminx# / 2) 
	maxy# = ((100/11.00)/100) * cubey#
	miny# = (maxy#-(100/11.00)/100) 
	halfy# = (maxy#/2 + miny# / 2) 


// create the cube 

	AddVertex(meshID,x# ,y#,z#						,0,1,0,   maxx#,halfy#,MakeColor(255,0,0))
	AddVertex(meshID,x#,y#+cubesize#,z#				,0,1,0,   maxx#,miny#,MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#,z#				,0,1,0,   halfx#,halfy#,MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#		,0,1,0,   halfx#,halfy#,MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#+cubesize#,z#		,0,1,0,   maxx#,miny#,MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#		,0,1,0,   halfx#,miny#,MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#  			,0,1,0		,maxx#	,miny#,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize#  	,0,1,0		,halfx#,miny#,MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#				,0,1,0		,maxx#,halfy#,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#				,0,1,0		,maxx#	,halfy#,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize#	,0,1,0		,halfx#	,miny#,MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#+-cubesize#	,0,1,0		,halfx#	,halfy#,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#+-cubesize#  	,0,1,0		,bottommaxx#,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#			,z#  			,0,1,0		,bottomhalfx#,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#  			,0,1,0		,bottommaxx#,halfy#,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#			,z#  			,0,1,0		,bottomhalfx#,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#+-cubesize#  	,0,1,0		,bottommaxx#,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#			,z#+-cubesize#  	,0,1,0		,bottomhalfx#	,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#			,z#+-cubesize#  	,0,1,0		,halfx#	,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#+-cubesize#  	,0,1,0		,maxx#	,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#+cubesize#,z#+-cubesize#  	,0,1,0		,halfx#,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize#  	,0,1,0		,maxx#,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#+cubesize#,z#+-cubesize#  	,0,1,0		,halfx#	,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#			,z#+-cubesize#  	,0,1,0		,maxx#	,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#,y#			,z#+-cubesize# 		 	,0,1,0		,maxx#	,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#,y#+cubesize#	,z# 		 			,0,1,0		,halfx#	,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#,y#			,z#  					,0,1,0		,halfx#,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#,y#+cubesize#	,z#			 			,0,1,0		,halfx#	,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#,y#			,z#+-cubesize#  			,0,1,0		,maxx#	, halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#,y#+cubesize#	,z#+-cubesize#  			,0,1,0		,maxx#	, miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#			,z#+-cubesize#  	,0,1,0		,halfx#,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#			,z#  			,0,1,0		,minx#,miny#,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#+cubesize#			,z#  			,0,1,0		,minx#,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#+cubesize#			,z#+-cubesize#  	,0,1,0		,halfx#	,halfy#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#+cubesize#,y#+cubesize#			,z#+-cubesize#  	,0,1,0		,halfx#,miny#	,	MakeColor(255,0,0))
	AddVertex(meshID,x#			,y#+cubesize#			,z#  			,0,1,0		,minx#,halfy#	,	MakeColor(255,0,0))

endfunction

Function AddVertex(m ref as Mesh, x as float, y as float, z as float, nx as float, ny as float, nz as float, u as float, v as float, color as integer)
	vert as vertex
	vert.x = x
	vert.y = y
	vert.z = z
	vert.nx = nx
	vert.ny = ny
	vert.nz = nz
	vert.u = u
	vert.v = v
	vert.color = color
	m.VertexList.Insert(vert)

endfunction

Function AddTriangle(m ref as Mesh, v1 as integer, v2 as integer, v3 as integer)
	t as Triangle
	t.v1 = v1
	t.v2 = v2
	t.v3 = v3
	m.TriangleList.Insert(t)
endfunction

Function CreateObjectFromMeshWithColor(m ref as mesh)
	VertexCount = m.VertexList.Length + 1
	IndexCount = (m.TriangleList.Length + 1) * 2
	IndexOffset = 72 + VertexCount*36
	memblock = CreateMemblock(IndexOffset+IndexCount*4)
	SetMemblockInt(memblock,0,VertexCount)
	SetMemblockInt(memblock,4,IndexCount)
	SetMemblockInt(Memblock,8,4)
	SetMemblockInt(memblock,12,32) // no color - 36 if color
	SetmemblockInt(memblock,16,72)
	SetMemblockInt(memblock,20,IndexOffset)
	SetMemblockInt(memblock,24,0x0c000300)
	SetMemblockString(Memblock,28,"position")
	SetMemblockInt(memblock,40,0x08000300)
	SetMemblockString(memblock,44,"normal")
	SetMemblockInt(memblock,52,0x04000200)
	SetMemblockString(memblock,56,"uv")
	SetMemblockInt(memblock,60,0x08010401) // maybe one day or year in 2019 lol
	SetMemblockString(memblock,64,"color") // maybe one day or year in 2019 lol
		for i = 0 to m.VertexList.Length
		SetMemblockFloat(memblock,72+i*36,m.VertexList[i].x)
		SetMemblockFloat(memblock,76+i*36,m.VertexList[i].y)
		SetMemblockFloat(memblock,80+i*36,m.VertexList[i].z)
		SetMemblockFloat(memblock,84+i*36,m.VertexList[i].nx)
		SetMemblockFloat(memblock,88+i*36,m.VertexList[i].ny)
		SetMemblockFloat(memblock,92+i*36,m.VertexList[i].nz)
		SetMemblockFloat(memblock,96+i*36,m.VertexList[i].u)
		SetMemblockFloat(memblock,100+i*36,m.VertexList[i].v)
		SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
	next
	
	for i = 0 to m.TriangleList.Length
		SetMemblockInt(memblock,IndexOffset+i*12,m.TriangleList[i].v1)
		SetMemblockInt(memblock,IndexOffset+i*12+4,m.TriangleList[i].v2)
		SetMemblockInt(memblock,IndexOffset+i*12+8,m.TriangleList[i].v3)
	next
	id = CreateObjectFromMeshMemblock(memblock)
//	DeleteMemblock(memblock)
endfunction id


Function CreateObjectFromMeshWithUVTexturing(m ref as mesh, mode)
	VertexCount = m.VertexList.Length + 1
	IndexCount = (m.TriangleList.Length + 1) * 2
	IndexOffset = 60 + VertexCount*36
	memblock = CreateMemblock(IndexOffset+IndexCount*4)
	SetMemblockInt(memblock,0,VertexCount)
	SetMemblockInt(memblock,4,IndexCount)
	SetMemblockInt(Memblock,8,3)
	SetMemblockInt(memblock,12,32) // no color - 36 if color
	SetmemblockInt(memblock,16,60)
	SetMemblockInt(memblock,20,IndexOffset)
	SetMemblockInt(memblock,24,0x0c000300)
	SetMemblockString(Memblock,28,"position")
	SetMemblockInt(memblock,40,0x08000300)
	SetMemblockString(memblock,44,"normal")
	SetMemblockInt(memblock,52,0x04000200)
	SetMemblockString(memblock,56,"uv")
	//SetMemblockInt(memblock,60,0x08010401) // maybe one day or year in 2019 lol
	//SetMemblockString(memblock,64,"color") // maybe one day or year in 2019 lol
		for i = 0 to m.VertexList.Length
		SetMemblockFloat(memblock,60+i*32,m.VertexList[i].x)
		SetMemblockFloat(memblock,64+i*32,m.VertexList[i].y)
		SetMemblockFloat(memblock,68+i*32,m.VertexList[i].z)
		SetMemblockFloat(memblock,72+i*32,m.VertexList[i].nx)
		SetMemblockFloat(memblock,76+i*32,m.VertexList[i].ny)
		SetMemblockFloat(memblock,80+i*32,m.VertexList[i].nz)
		SetMemblockFloat(memblock,84+i*32,m.VertexList[i].u)
		SetMemblockFloat(memblock,88+i*32,m.VertexList[i].v)
		//SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
	next
	
//	for i = 0 to m.TriangleList.Length
//		SetMemblockInt(memblock,IndexOffset+i*12,m.TriangleList[i].v1)
//		SetMemblockInt(memblock,IndexOffset+i*12+4,m.TriangleList[i].v2)
//		SetMemblockInt(memblock,IndexOffset+i*12+8,m.TriangleList[i].v3)
//	next
	DeleteObject(id)
	id = CreateObjectFromMeshMemblock(memblock)

	if mode=1 // creates the world or it creates for other small things - like explosion blocks
		// we need to keep the world chunk in memory so we can keep updating the vertices
		meshmemory = memblock
	endif
	
//	DeleteMemblock(memblock)
endfunction id
Posted: 2nd Sep 2018 19:36
Thankyou
Posted: 3rd Sep 2018 21:33
3D Letters
+ Code Snippet
// Project: 3D Letters 
// Created: 2018-08-04
 
// show all errors
SetErrorMode(2)
 
 #constant PI# = 3.14159265359
 
// set window properties
SetWindowTitle( "3D Letters" )
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( 0, 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 Vertex
     
    x as float
    y as float
    z as float
    nx as float
    ny as float
    nz as float
    u as float
    v as float
    color as integer
endtype
 
Type Triangle
    v1 as integer
    v2 as integer
    v3 as integer
endtype
 
Type Mesh
    VertexList as Vertex[]
    TriangleList as Triangle[]
endtype
 
global MeshID as Mesh
CubeD = LoadImage("\media\cube.png")

// this empties the mesh
MeshID.TriangleList.length=-1
MeshID.VertexList.length=-1

		CreateMeshObjectBoxWithTexture(5,0,0,3,5,2)
		CreateMeshObjectConeWithTexture(10,9,5,1)


object = CreateObjectFromMeshWithUVTexturing(MeshID,CubeD)

SetObjectScale(object,.4,.4,.4) 
do
 //   RotateObjectLocalX(object,.1)
    RotateObjectLocalY(object,.05)
   RotateObjectLocalZ(object,.05)
     
    Print( ScreenFPS() )
    Sync()
loop


function createMeshObjectCylinderWithTexture(height#, diameter#, segments#)
	
	
	
endfunction
function CreateMeshObjectConeWithTexture(height#, segments#, Radius#, Bottom)
	
	color=MakeColor(255,255,255) // doesnt use color but the AddVertex requires it 
	faces = segments# * 2
	SegX# = 2 * PI# / segments#

	for i = 0 to segments#
		
		nxt = i+1
		if (nxt >= segments#) then nxt=0
	
		AddVertex(MeshID, 0								, height#/2.0	,0						, 0,1,0, .5,.5,Color)
			
		AddVertex(MeshID, SinRad(-SegX#*i)*radius#		,-height#/2.0	,CosRad(-SegX#*i) * radius#, sinrad( -SegX#*i),abs(radius#)/height#,cosRad(-SegX#*i),SinRad( -SegX# * i ) /2.0 +.5, CosRad(-SegX# * i)/2.0 + .5,Color)
			
		AddVertex(MeshID, SinRad(-SegX#*nxt)*radius#	,-height#/2.0	,CosRad(-SegX#*nxt) * radius#, SinRad(-SegX#*nxt),abs(radius#)/height#,CosRad(-SegX# * nxt),SinRad(-SegX# * (i+1) )/2.0 + .5, CosRad(-SegX#*(i+1)) /2.0+.5,Color)
	next
	
	
	if bottom=1 
		
		for i = 0 to segments#
		
			nxt = i+1
			if (nxt >= segments#) then nxt=0
	
			AddVertex(MeshID, SinRad(-SegX#*i)*radius#		,-height#/2.0	,CosRad(-SegX#*i) * radius#, 0,-height#,0,SinRad( -SegX#*i) /2.0+.5,CosRad(-SegX#*i)/2.0+.5,Color)

			AddVertex(MeshID, 0								, -height#/2.0	,0						, 0,-height#,0, .5,.5,Color)
			
			AddVertex(MeshID, SinRad(-SegX#*nxt)*radius#	,-height#/2.0	,CosRad(-SegX#*nxt) * radius#, 0,-height#,0,SinRad(-SegX#*(i+1))/2.0+.5,CosRad(-SegX#*(i+1))/2.0+.5,Color)
		next
	endif

endfunction MeshID
 
 function CreateMeshObjectBoxWithTexture(X#, Y#, Z#, Width#, Height#, Depth#)
	Color= MakeColor(255,255,255) // This doesnt use color but AddVertex requires it
	
	
//Front Face	
	AddVertex(MeshID, X#			,y#				,Z#, 0,1,0, 0,1,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#, 0,1,0, 1,0,Color)
	AddVertex(MeshID, X#			,y#+height#		,Z#, 0,1,0, 0,0,Color)
	AddVertex(MeshID, X#			,y#				,Z#, 0,1,0, 0,1,Color)
	AddVertex(MeshID, X#+width#		,y#				,Z#, 0,1,0, 1,1,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#, 0,1,0, 1,0,Color)	

// Left
	AddVertex(MeshID, X#			,y#				,Z#			, 0,1,0, 1,1,Color)
	AddVertex(MeshID, X#			,y#+height#		,Z#			, 0,1,0, 1,0,Color)
	AddVertex(MeshID, X#			,y#				,Z#+depth#		, 0,1,0, 0,1,Color)
	AddVertex(MeshID, X#			,y#+height#		,Z#			, 0,1,0, 1,0,Color)
	AddVertex(MeshID, X#			,y#+height#		,Z#+depth#		, 0,1,0, 0,0,Color)
	AddVertex(MeshID, X#			,y#				,Z#+depth#		, 0,1,0, 0,1,Color)
	


// Right
	AddVertex(MeshID, X#+width#		,y#				,Z#		, 0,1,0		, 0,1,Color)
	AddVertex(MeshID, X#+width#		,y#				,Z#+depth#	, 0,1,0	, 1,1,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#		, 0,1,0		, 0,0,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#		, 0,1,0		, 0,0,Color)
	AddVertex(MeshID, X#+width#		,y#				,Z#+depth#, 0,1,0		, 1,1,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#+depth#	, 0,1,0		, 1,0,Color)
	


//back
	AddVertex(MeshID, X#			,y#				,Z#+depth#, 0,1,0, 1,1,Color)
	AddVertex(MeshID, X#			,y#+height#		,Z#+depth#, 0,1,0, 1,0,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#+depth#, 0,1,0, 0,0,Color)
	AddVertex(MeshID, X#			,y#				,Z#+depth#, 0,1,0, 1,1,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#+depth#, 0,1,0, 0,0,Color)	
	AddVertex(MeshID, X#+width#		,y#				,Z#+depth#, 0,1,0, 0,1,Color)


// top
	AddVertex(MeshID, X#			,y#+height#		,Z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#			, 0,1,0, 0,1,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#+depth#	, 0,1,0, 1,1,Color)
	AddVertex(MeshID, X#			,y#+height#		,Z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, X#+width#		,y#+height#		,Z#+depth#	, 0,1,0, 1,1,Color)
	AddVertex(MeshID, X#			,y#+height#		,Z#+depth#	, 0,1,0, 1,0,Color)
	


//bottom
	AddVertex(MeshID, X#			,y#				,Z#			, 0,1,0, 0,1,Color)
	AddVertex(MeshID, X#+width#		,y#				,Z#+depth#		, 0,1,0, 1,0,Color)
	AddVertex(MeshID, X#+width#		,y#				,Z#			, 0,1,0, 0,0,Color)
	AddVertex(MeshID, X#			,y#				,Z#			, 0,1,0, 0,1,Color)
	AddVertex(MeshID, X#			,y#				,Z#+depth#		, 0,1,0, 1,1,Color)
	AddVertex(MeshID, X#+width#		,y#				,Z#+depth#		, 0,1,0, 1,0,Color)

endfunction MeshID

 
function addcube(meshID ref as mesh, cubesize#, tilenumberx, tilenumbery, normx#,normy#,normz#,x#,y#,z#)
 
// calculate the UVs  - YIKES here we go
    cubex#=((tilenumberx-1) * .5) + tilenumberx // 
    cubey#=(tilenumbery * 0.5)+ 0.5
    maxx# = ((100/15.00)/100) * cubex#
    minx# = (maxx#-(100/15.00)/100)
    halfx# = (maxx#/2 + minx# / 2) 
    bottommaxx# = ((100/15.00)/100) * (cubex#+.5)
    bottomminx# = (bottommaxx#-((100/15.00)/100))
    bottomhalfx# = (bottommaxx#/2 + bottomminx# / 2) 
    maxy# = ((100/11.00)/100) * cubey#
    miny# = (maxy#-(100/11.00)/100) 
    halfy# = (maxy#/2 + miny# / 2) 
 
 
// create the cube 
 
    AddVertex(meshID,x# ,y#,z#                      ,0,1,0,   maxx#,halfy#,MakeColor(255,0,0))
    AddVertex(meshID,x#,y#+cubesize#,z#             ,0,1,0,   maxx#,miny#,MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#,z#             ,0,1,0,   halfx#,halfy#,MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#     ,0,1,0,   halfx#,halfy#,MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#+cubesize#,z#        ,0,1,0,   maxx#,miny#,MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#       ,0,1,0,   halfx#,miny#,MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#           ,0,1,0      ,maxx#  ,miny#, MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize#    ,0,1,0      ,halfx#,miny#,MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#             ,0,1,0      ,maxx#,halfy#,  MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#             ,0,1,0      ,maxx#  ,halfy#,    MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize#    ,0,1,0      ,halfx# ,miny#,MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#+-cubesize#  ,0,1,0      ,halfx# ,halfy#,    MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#+-cubesize#      ,0,1,0      ,bottommaxx#,miny#  ,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#         ,z#             ,0,1,0      ,bottomhalfx#,halfy#    ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#             ,0,1,0      ,bottommaxx#,halfy#,    MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#         ,z#             ,0,1,0      ,bottomhalfx#,halfy#    ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#+-cubesize#      ,0,1,0      ,bottommaxx#,miny#  ,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#         ,z#+-cubesize#      ,0,1,0      ,bottomhalfx#   ,miny#  ,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#         ,z#+-cubesize#      ,0,1,0      ,halfx# ,halfy# ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#+-cubesize#      ,0,1,0      ,maxx#  ,halfy# ,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#+cubesize#,z#+-cubesize#     ,0,1,0      ,halfx#,miny#   ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#,z#+-cubesize#    ,0,1,0      ,maxx#,miny#    ,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#+cubesize#,z#+-cubesize#     ,0,1,0      ,halfx# ,miny#  ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#            ,z#+-cubesize#      ,0,1,0      ,maxx#  ,halfy# ,   MakeColor(255,0,0))
    AddVertex(meshID,x#,y#          ,z#+-cubesize#          ,0,1,0      ,maxx#  ,halfy# ,   MakeColor(255,0,0))
    AddVertex(meshID,x#,y#+cubesize#    ,z#                     ,0,1,0      ,halfx# ,miny#  ,   MakeColor(255,0,0))
    AddVertex(meshID,x#,y#          ,z#                     ,0,1,0      ,halfx#,halfy#  ,   MakeColor(255,0,0))
    AddVertex(meshID,x#,y#+cubesize#    ,z#                     ,0,1,0      ,halfx# ,miny#  ,   MakeColor(255,0,0))
    AddVertex(meshID,x#,y#          ,z#+-cubesize#              ,0,1,0      ,maxx#  , halfy#    ,   MakeColor(255,0,0))
    AddVertex(meshID,x#,y#+cubesize#    ,z#+-cubesize#              ,0,1,0      ,maxx#  , miny# ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#          ,z#+-cubesize#      ,0,1,0      ,halfx#,miny#   ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#          ,z#             ,0,1,0      ,minx#,miny#,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#+cubesize#           ,z#             ,0,1,0      ,minx#,halfy#   ,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#+cubesize#           ,z#+-cubesize#      ,0,1,0      ,halfx# ,halfy# ,   MakeColor(255,0,0))
    AddVertex(meshID,x#+cubesize#,y#+cubesize#          ,z#+-cubesize#      ,0,1,0      ,halfx#,miny#   ,   MakeColor(255,0,0))
    AddVertex(meshID,x#         ,y#+cubesize#           ,z#             ,0,1,0      ,minx#,halfy#   ,   MakeColor(255,0,0))
 
endfunction
 
Function AddVertex(m ref as Mesh, x as float, y as float, z as float, nx as float, ny as float, nz as float, u as float, v as float, color as integer)
    vert as vertex
    vert.x = x
    vert.y = y
    vert.z = z
    vert.nx = nx
    vert.ny = ny
    vert.nz = nz
    vert.u = u
    vert.v = v
    vert.color = color
    m.VertexList.Insert(vert)
 
endfunction
 
Function AddTriangle(m ref as Mesh, v1 as integer, v2 as integer, v3 as integer)
    t as Triangle
    t.v1 = v1
    t.v2 = v2
    t.v3 = v3
    m.TriangleList.Insert(t)
endfunction
 
Function CreateObjectFromMeshWithColor(m ref as mesh)
    VertexCount = m.VertexList.Length + 1
    IndexCount = (m.TriangleList.Length + 1) * 2
    IndexOffset = 72 + VertexCount*36
    memblock = CreateMemblock(IndexOffset+IndexCount*4)
    SetMemblockInt(memblock,0,VertexCount)
    SetMemblockInt(memblock,4,IndexCount)
    SetMemblockInt(Memblock,8,4)
    SetMemblockInt(memblock,12,32) // no color - 36 if color
    SetmemblockInt(memblock,16,72)
    SetMemblockInt(memblock,20,IndexOffset)
    SetMemblockInt(memblock,24,0x0c000300)
    SetMemblockString(Memblock,28,"position")
    SetMemblockInt(memblock,40,0x08000300)
    SetMemblockString(memblock,44,"normal")
    SetMemblockInt(memblock,52,0x04000200)
    SetMemblockString(memblock,56,"uv")
    SetMemblockInt(memblock,60,0x08010401) // maybe one day or year in 2019 lol
    SetMemblockString(memblock,64,"color") // maybe one day or year in 2019 lol
        for i = 0 to m.VertexList.Length
        SetMemblockFloat(memblock,72+i*36,m.VertexList[i].x)
        SetMemblockFloat(memblock,76+i*36,m.VertexList[i].y)
        SetMemblockFloat(memblock,80+i*36,m.VertexList[i].z)
        SetMemblockFloat(memblock,84+i*36,m.VertexList[i].nx)
        SetMemblockFloat(memblock,88+i*36,m.VertexList[i].ny)
        SetMemblockFloat(memblock,92+i*36,m.VertexList[i].nz)
        SetMemblockFloat(memblock,96+i*36,m.VertexList[i].u)
        SetMemblockFloat(memblock,100+i*36,m.VertexList[i].v)
        SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
    next
     
    for i = 0 to m.TriangleList.Length
        SetMemblockInt(memblock,IndexOffset+i*12,m.TriangleList[i].v1)
        SetMemblockInt(memblock,IndexOffset+i*12+4,m.TriangleList[i].v2)
        SetMemblockInt(memblock,IndexOffset+i*12+8,m.TriangleList[i].v3)
    next
    id = CreateObjectFromMeshMemblock(memblock)
//  DeleteMemblock(memblock)
endfunction id
 
 
Function CreateObjectFromMeshWithUVTexturing(m ref as mesh, texture)
    VertexCount = m.VertexList.Length + 1
    IndexCount = (m.TriangleList.Length + 1) * 2
    IndexOffset = 60 + VertexCount*36
    memblock = CreateMemblock(IndexOffset+IndexCount*4)
    SetMemblockInt(memblock,0,VertexCount)
    SetMemblockInt(memblock,4,IndexCount)
    SetMemblockInt(Memblock,8,3)
    SetMemblockInt(memblock,12,32) // no color - 36 if color
    SetmemblockInt(memblock,16,60)
    SetMemblockInt(memblock,20,IndexOffset)
    SetMemblockInt(memblock,24,0x0c000300)
    SetMemblockString(Memblock,28,"position")
    SetMemblockInt(memblock,40,0x08000300)
    SetMemblockString(memblock,44,"normal")
    SetMemblockInt(memblock,52,0x04000200)
    SetMemblockString(memblock,56,"uv")
    //SetMemblockInt(memblock,60,0x08010401) // maybe one day or year in 2019 lol
    //SetMemblockString(memblock,64,"color") // maybe one day or year in 2019 lol
        for i = 0 to m.VertexList.Length
        SetMemblockFloat(memblock,60+i*32,m.VertexList[i].x)
        SetMemblockFloat(memblock,64+i*32,m.VertexList[i].y)
        SetMemblockFloat(memblock,68+i*32,m.VertexList[i].z)
        SetMemblockFloat(memblock,72+i*32,m.VertexList[i].nx)
        SetMemblockFloat(memblock,76+i*32,m.VertexList[i].ny)
        SetMemblockFloat(memblock,80+i*32,m.VertexList[i].nz)
        SetMemblockFloat(memblock,84+i*32,m.VertexList[i].u)
        SetMemblockFloat(memblock,88+i*32,m.VertexList[i].v)
        //SetMemblockInt(memblock,104+i*36,m.VertexList[i].color) //maybe one day or year in 2019 lol
    next
     
//  for i = 0 to m.TriangleList.Length
//      SetMemblockInt(memblock,IndexOffset+i*12,m.TriangleList[i].v1)
//      SetMemblockInt(memblock,IndexOffset+i*12+4,m.TriangleList[i].v2)
//      SetMemblockInt(memblock,IndexOffset+i*12+8,m.TriangleList[i].v3)
//  next
    DeleteObject(id)
    id = CreateObjectFromMeshMemblock(memblock)
	SetObjectImage(id,texture,0)
 
//    if mode=1 // creates the world or it creates for other small things - like explosion blocks
        // we need to keep the world chunk in memory so we can keep updating the vertices
        meshmemory = memblock
//    endif
     
//  DeleteMemblock(memblock)
endfunction id

Posted: 5th Sep 2018 0:59
A 3d Atmosphere Background Shader just place on a object plane at the back of your scene
vs shader
+ Code Snippet
attribute vec4 position;
attribute vec4 color;
attribute vec2 uv;

varying vec2 uvVarying;
varying vec4 colorVarying;
varying vec3 posVarying;

uniform mat4 agk_Ortho;
uniform highp mat4 agk_World;
uniform highp mat4 agk_ViewProj;

void main()
{ 
	//gl_Position = agk_Ortho * position;
	highp vec4 pos = agk_World * vec4(position);
	gl_Position = agk_ViewProj * pos;
	posVarying = position.xyz;
	uvVarying = uv;
	colorVarying = color;
}



ps code
+ Code Snippet
#ifdef GL_ES
precision mediump float;
#endif

#extension GL_OES_standard_derivatives : enable

#define NUM_OCTAVES 16

uniform float time;
uniform vec2 resolution;

mat3 rotX(float a) {
	float c = cos(a);
	float s = sin(a);
	return mat3(
		1, 0, 0,
		0, c, -s,
		0, s, c
	);
}
mat3 rotY(float a) {
	float c = cos(a);
	float s = sin(a);
	return mat3(
		c, 0, -s,
		0, 1, 0,
		s, 0, c
	);
}

float random(vec2 pos) {
	return fract(sin(dot(pos.xy, vec2(12.9898, 78.233))) * 43758.5453123);
}

float noise(vec2 pos) {
	vec2 i = floor(pos);
	vec2 f = fract(pos);
	float a = random(i + vec2(0.0, 0.0));
	float b = random(i + vec2(1.0, 0.0));
	float c = random(i + vec2(0.0, 1.0));
	float d = random(i + vec2(1.0, 1.0));
	vec2 u = f * f * (3.0 - 2.0 * f);
	return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
}

float fbm(vec2 pos) {
	float v = 0.0;
	float a = 0.5;
	vec2 shift = vec2(100.0);
	mat2 rot = mat2(cos(0.5), sin(0.5), -sin(0.5), cos(0.5));
	for (int i=0; i<NUM_OCTAVES; i++) {
		v += a * noise(pos);
		pos = rot * pos * 2.0 + shift;
		a *= 0.5;
	}
	return v;
}

void main(void) {
	vec2 p = (gl_FragCoord.xy * 2.0 - resolution.xy) / min(resolution.x, resolution.y);

	float t = 0.0, d;
	
	float time2 = 3.0 * time / 2.0;
	
	vec2 q = vec2(0.0);
	q.x = fbm(p + 0.00 * time2);
	q.y = fbm(p + vec2(1.0));
	vec2 r = vec2(0.0);
	r.x = fbm(p + 1.0 * q + vec2(1.7, 9.2) + 0.15 * time2);
	r.y = fbm(p + 1.0 * q + vec2(8.3, 2.8) + 0.126 * time2);
	float f = fbm(p + r);
	vec3 color = mix(
		vec3(0.101961, 1.866667, 0.319608),
		vec3(0.366667, 1.598039, 0.366667),
		clamp((f * f) * 4.0, 0.0, 1.0)
	);

	color = mix(
		color,
		vec3(0, 0, 0.164706),
		clamp(length(q), 0.0, 1.0)
	);


	color = mix(
		color,
		vec3(0.666667, 1, 0.6),
		clamp(length(r.x), 0.0, 1.0)
	);

	color = (f *f * f + 0.6 * f * f + 0.5 * f) * color;
	
	gl_FragColor = vec4(color, 1.0);
}
Posted: 7th Sep 2018 3:53
3D Exploding Block
+ Code Snippet
SetWindowTitle( "Explosion" )
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

#constant KEY_SPACE	  = 32  //the space bar
#constant KEY_LEFT    = 37  //the left arrow key scancode
#constant KEY_UP      = 38  //the up arrow key scancode
#constant KEY_RIGHT   = 39  //the right arrow key scancode
#constant KEY_DOWN    = 40  //the down arrow key scancode
SetGenerateMipmaps( 1 )

type face
	ID as integer
	x as float
	y as float
	z as float
	xOld as float
	yOld as float
	zOld as float
	xAng as float
	yAng as float
	zAng as float
	xAngOld as float
	yAngOld as float
	zAngOld as float
	time as float //to be implimented
endtype

global faces as face[]

CreateObjectBox(10,2,2,2)
SetObjectColor(10,0,255,0,255)

// main loop
do
		if GetRawKeyState(KEY_LEFT) then MoveObjectLocalX(10,-1)
		if GetRawKeyState(KEY_RIGHT) then MoveObjectLocalX(10,1)
		if GetRawKeyState(KEY_UP) then MoveObjectLocalY(10,1)
		if GetRawKeyState(KEY_DOWN) then MoveObjectLocalY(10,-1)
		if GetRawKeyPressed(KEY_SPACE) then explosionSetup(10)
			
			
		if faces.length+1 >0 then updateExplosion()
		//if faces.length <=1 then explosionSetup(10) 
		if faces.length <=1  then SetObjectVisible(10,1) 
		
		Print ("Move green block with arrow keys")
		Print ("Press space to self destruct")
		
        sync()
loop

function updateExplosion()
	SetObjectVisible(10,0)
	for num =0 to faces.length-1
		SetObjectVisible(faces[num].ID,1)
		if faces[num].x > faces[num].xOld 
			offsetX=random(0,1)
		else 
			offsetX=-random(0,1)
		endif	
		if faces[num].y > faces[num].yOld 
			offsetY=random(0,1)
		else 
			offsetY=-random(0,1)
		endif	
		if faces[num].z > faces[num].zOld 
			offsetZ=random(0,1)
		else 
			offsetZ=-random(0,1)
		endif	
		SetObjectPosition(faces[num].ID,faces[num].x+offsetX,faces[num].y+offsetY,faces[num].z+offsetZ)
		faces[num].x=GetObjectX(faces[num].ID)
		faces[num].y=GetObjectY(faces[num].ID)
		faces[num].z=GetObjectZ(faces[num].ID)
		if faces[num].xAng > faces[num].xAngOld 
			offsetAngX=random(0,10)
		else 
			offsetAngX=-random(0,10)
		endif	
		if faces[num].yAng > faces[num].yAngOld 
			offsetAngY=random(0,10)
		else 
			offsetAngY=-random(0,10)
		endif	
		if faces[num].zAng > faces[num].zAngOld 
			offsetAngZ=random(0,10)
		else 
			offsetAngZ=-random(0,10)
		endif	
		SetObjectRotation(faces[num].ID,faces[num].xAng+offsetAngX,faces[num].yAng+offsetAngY,faces[num].zAng+offsetAngZ)
		faces[num].xAng=GetObjectAngleX(faces[num].ID)
		faces[num].yAng=GetObjectAngleY(faces[num].ID)
		faces[num].zAng=GetObjectAngleZ(faces[num].ID)
		if timer()>faces[num].time+1
			deleteObject(faces[num].ID)
			faces.remove(num)
		endif
	next num	
endfunction

function explosionSetup(id as integer)
myFace as face
myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id),getObjectZ(id)+1)
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)

myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id),getObjectZ(id)-1)
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)

myFace.ID=CreateObjectBox(.25,2,2)
SetObJectPosition(myFace.ID,getObjectX(id)-1,getObjectY(id),getObjectZ(id))
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)

myFace.ID=CreateObjectBox(.5,2,2)
SetObJectPosition(myFace.ID,getObjectX(id)+1,getObjectY(id),getObjectZ(id))
SetObjectRotation(myFace.ID,getObjectAngleX(id),GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)

myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id)+1,getObjectZ(id))
SetObjectRotation(myFace.ID,getObjectAngleX(id)+90,GetObjectAngleY(id),GetObjectAngleZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)

myFace.ID=CreateObjectBox(2,2,.25)
SetObJectPosition(myFace.ID,getObjectX(id),getObjectY(id)-1,getObjectZ(id))
SetObjectRotation(myFace.ID,GetObjectAngleX(id)+90,getObjectY(id),getObjectZ(id))
SetObjectVisible(myFace.ID,0)
SetObjectcolor(myFace.ID,255,0,0,255)
MyFace.x=GetObjectX(myFace.ID)
MyFace.y=GetObjectY(myFace.ID)
MyFace.z=GetObjectZ(myFace.ID)
MyFace.xAng=GetObjectAngleX(myFace.ID)
MyFace.yAng=GetObjectAngleY(myFace.ID)
MyFace.zAng=GetObjectAngleZ(myFace.ID)
myFace.xOld=myFace.x
myFace.yOld=myFace.y
myFace.zOld=myFace.z
MyFace.xAngOld=myFace.xAng
MyFace.yAngOld=myFace.yAng
MyFace.zAngOld=myFace.zAng
MyFace.time=timer()
faces.insert(myFace)

for num =0 to faces.length-1
	faces[num].x=faces[num].x+Random2(-2,2)
	faces[num].y=faces[num].y+Random2(-2,2)
	faces[num].z=faces[num].z+Random2(-2,2)
	faces[num].xAng=faces[num].xAng+Random2(-2,2)
	faces[num].yAng=faces[num].yAng+Random2(-2,2)
	faces[num].zAng=faces[num].zAng+Random2(-2,2)
next num
	
endfunction


Ideally you want several models that are parts of one whole model they would all share the same location, offsets and textures
Posted: 1st Nov 2018 20:24
A gyroscopic mouse
+ Code Snippet
// show all errors
SetErrorMode(2)
 
// set window properties
SetWindowTitle( "gyro-mouse" )
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
spr=CreateSprite(0)
SetSpriteSize(spr,10,10)
SetSpriteColor(spr,255,255,255,255)
SetSpritePosition(spr,100,100)
do 
	print(str(GetDirectionX()))
	SetSpritePositionByOffset(spr,GetDirectionX()*(GetDeviceWidth()/2.0)+(GetDeviceWidth()/2.0),GetDirectionY()*(GetDeviceHeight()/2.0)+(GetDeviceHeight()/2.0))
	sync()
loop


very simple piece of code but can be quite handy


you could also change
+ Code Snippet
SetSpritePositionByOffset(spr,GetDirectionX()*(GetDeviceWidth()/2.0)+(GetDeviceWidth()/2.0),GetDirectionY()*(GetDeviceHeight()/2.0)+(GetDeviceHeight()/2.0))

to this for a 45 degree offset
+ Code Snippet
SetSpritePositionByOffset(spr,GetDirectionX()*(GetDeviceWidth()/2.0)+(GetDeviceWidth()/2.0),-(GetDirectionY()-.45)*(GetDeviceHeight()*.45)+(GetDeviceHeight()*.65))
Posted: 16th Nov 2018 10:28
Not so usefull to most the people who use this forum
But I wrote a PDF one weekend quite a while ago
Performing PC;s For Dummies
available free here http://users.tpg.com.au/subarpk/Performing%20PC's%20For%20Dummies.pdf


It covers all versions of windows with pretty pics but needs updating for windows 10
Posted: 16th Nov 2018 14:00
Wow - thats super impressive Fuparpk and would help people a lot make there systems run a bit smoother.

Is it possible to make a slight change? - 1MB equates to 1024 bytes not 1000

But awesome material apart from that
Posted: 16th Nov 2018 15:50
1MB equates to 1024 bytes not 1000


Of ofcourse lol it was thrown together on a weekend maybe I thought it was simpler to understand I don't remember lol
Posted: 17th Nov 2018 18:15
Hope you dont mind the add

Object / File encrypter

+ Code Snippet
// Project: encrypter 
// Created: 2018-11-17

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "encrypter" )
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

#constant size = 128
global encryptionkey as integer[size,size]

generatebitmask(size,size)



//LoadObject("\media\cube.obj")

	for x=0 to size
		for y=0 to size
				c=MakeColor(encryptionkey[x,y],encryptionkey[x,y],encryptionkey[x,y])
				DrawLine(x,y,x,y,c,c,c)
		next
	next
		
	file = OpenToRead("\media\cube.obj")
	newfile = OpenToWrite("\media\cube.agm")
	WriteLine(newfile,"AGM!")
	writebyte(newfile,size)
	WriteLine(newfile,"cube.obj")
	WriteInteger(newfile, GetFileSize(file))
	
	enclocx=0
	enclocy=0
	
	while not FileEOF(file)
	
		WriteByte(newfile,encryptionkey[enclocx,enclocy])
		WriteInteger(newfile, ReadInteger(file) ~~ encryptionkey[enclocx,enclocy])
		
		inc enclocx
		if enclocx>size 
			enclocx=0
			inc enclocy
		endif
		if enclocy>size
			enclocx=0
			enclocy=0
		endif
		
		
	endwhile
	WriteLine(newfile,"AGM!")
	CloseFile(newfile)
	CloseFile(file)


do
	print ("CUBE.AGM - created")
    Print( ScreenFPS() )
    Sync()
loop

function generatebitmask(sizex,sizey)
	
	for x=0 to sizex
		for y=0 to sizey
			encryptionkey[x,y]=random2(0,255)
				
		next
	next
	
	
	
endfunction


Decrypter
+ Code Snippet
// Project: encrypter 
// Created: 2018-11-17

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "encrypter" )
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

#constant size = 128
global encryptionkey as integer[size,size]

generatebitmask(size,size)



//LoadObject("\media\cube.obj")

	for x=0 to size
		for y=0 to size
				c=MakeColor(encryptionkey[x,y],encryptionkey[x,y],encryptionkey[x,y])
				DrawLine(x,y,x,y,c,c,c)
		next
	next
		
	file = OpenToRead("\media\cube.obj")
	newfile = OpenToWrite("\media\cube.agm")
	WriteLine(newfile,"AGM!")
	writebyte(newfile,size)
	WriteLine(newfile,"cube.obj")
	WriteInteger(newfile, GetFileSize(file))
	
	enclocx=0
	enclocy=0
	
	while not FileEOF(file)
	
		WriteByte(newfile,encryptionkey[enclocx,enclocy])
		WriteInteger(newfile, ReadInteger(file) ~~ encryptionkey[enclocx,enclocy])
		
		inc enclocx
		if enclocx>size 
			enclocx=0
			inc enclocy
		endif
		if enclocy>size
			enclocx=0
			enclocy=0
		endif
		
		
	endwhile
	WriteLine(newfile,"AGM!")
	CloseFile(newfile)
	CloseFile(file)


do
	print ("CUBE.AGM - created")
    Print( ScreenFPS() )
    Sync()
loop

function generatebitmask(sizex,sizey)
	
	for x=0 to sizex
		for y=0 to sizey
			encryptionkey[x,y]=random2(0,255)
				
		next
	next
	
	
	
endfunction


Encrypt object, like a OBJ file

Decrypt - the AGM file - these are the files that should be packaged up to your distributions

It can be tidied up a lot, but this is the principle and though would be useful here instead of the meshmemblock thread
Posted: 17th Nov 2018 18:19
Thanks Puzzler
Posted: 18th Nov 2018 17:04
Here is version 2 (includes a packager)

Encryption module - run this on your media before when your ready to ship - keep a backup of the media

+ Code Snippet
// Project: enctest 
// Created: 2018-11-17

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "enctest" )
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

#constant size = 128
global encryptionkey as integer[size,size]

package("assets.agm")

do
    Print( ScreenFPS() )
    Sync()
loop


function generatebitmask(sizex,sizey)
	
	for x=0 to sizex
		for y=0 to sizey
			encryptionkey[x,y]=random2(200,255)
				
		next
	next
endfunction

function package(filename$)
	generatebitmask(size,size)

	newfile = OpenToWrite(filename$)

	fn$=GetFirstFile()
	while fn$<>""
		if fn$<>"bytecode.byc" and fn$<>filename$ // dont encrypt the bytecode or itself (if ever it finds them)
			file = OpenToRead(fn$)
			WriteLine(newfile,"AGM!")
			writebyte(newfile,size)
			WriteLine(newfile,fn$)
			WriteInteger(newfile, GetFileSize(file))

			enclocx=0
			enclocy=0
			length=GetFileSize(file)
			for a=0 to length
				WriteByte(newfile,encryptionkey[enclocx,enclocy])
				WriteByte(newfile, (ReadByte(file) ~~ (encryptionkey[enclocx,enclocy]+a)) ~~a)
				
				inc enclocx
				if enclocx>size 
					enclocx=0
					inc enclocy
				endif
				if enclocy>size
					enclocx=0
					enclocy=0
				endif
		
		
			next
			WriteLine(newfile,"AGM!")
	
			CloseFile(file)
		endif
		fn$=GetNextFile()
	endwhile

	CloseFile(newfile)
endfunction


Decrypter - use these functions in your app along with the AGM fiie that the above creates

+ Code Snippet
// Project: enctest 
// Created: 2018-11-17

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "enctest" )
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 _strings
	id
	txt
	fontsize
	x
	y
	rotate#
	angle#
	colorred
	colorgreen
	colorblue
	coloralpha
endtype
global strings as _strings[]



unpackage("assets.agm")

// What do we think is inside the Assets.agm
cube = AGM_LoadObject("cube.obj")
cone = AGM_LoadObject("cone.obj")
ico = AGM_LoadObject("ico.obj")


cubepng=AGM_LoadImage("cobe.png")
conepng=AGM_LoadImage("cone.png")
icopng=AGM_LoadImage("ico.png")

music = AGM_LoadMusic(1, "overworld.ogg")

agm_loadstrings("strings.txt")

SetObjectPosition(cube,-10,0,0)
SetObjectPosition(cone,0,0,0)
SetObjectPosition(ico,10,0,0)

SetObjectImage(cube,cubepng,0)
SetObjectImage(cone,conepng,0)
SetObjectImage(ico,icopng,0)




c=CreateObjectBox(2,2,2)
SetObjectImage(c,conepng,0)
SetObjectPosition(c,-10,4,0)
c=CreateObjectBox(2,2,2)
SetObjectImage(c,cubepng,0)
SetObjectPosition(c,0,4,0)
c=CreateObjectBox(2,2,2)
SetObjectImage(c,icopng,0)
SetObjectPosition(c,10,4,0)

PlayMusicOGG(music)
do
	
	
	for a=0 to strings.length
		SetTextPosition(strings[a].id,strings[a].x,strings[a].y)
	
		SetTextAngle(strings[a].id,strings[a].angle#)
		inc strings[a].angle#,strings[a].rotate#
		
	next

    Print( ScreenFPS() )
    Sync()
loop


function AGM_loadstrings(filename$)
	s as _strings
	
	file  = OpenToRead(filename$)
	
	while not FileEOF(file)
		line$=ReadLine(file)
		s.id = CreateText(GetStringToken(line$,",",1))
		s.fontsize = val(GetStringToken(line$,",",2))
		s.x		= val(GetStringToken(line$,",",3))
		s.y		= val(GetStringToken(line$,",",4))
		s.rotate#		= ValFloat(GetStringToken(line$,",",5))
		s.colorred = val(GetStringToken(line$,",",6))
		s.colorgreen = val(GetStringToken(line$,",",7))
		s.colorblue = val(GetStringToken(line$,",",8))
		s.coloralpha = val(GetStringToken(line$,",",9))
		
		SetTextColor(s.id,s.colorred,s.colorgreen,s.colorblue,s.coloralpha)
		SetTextSize(s.id,s.fontsize)
		
		strings.insert(s)
		
		
	endwhile
	
	CloseFile(file)	
		
	DeleteFile(filename$)
	
endfunction


function AGM_LoadMusic(id, file$)
	
	LoadMusicOGG(id,file$)
	DeleteFile(file$)
endfunction id

function AGM_LoadObject(file$)
	id = LoadObject(file$)
	DeleteFile(file$)
endfunction id

function AGM_LoadImage(file$)
	id = LoadImage(file$)
	DeleteFile(file$)
endfunction id


function unpackage(filename$)

	newfile = OpenToRead(filename$)
  	while not FileEOF(newfile)
		if (readLine(newfile)="AGM!") 
		
			size = readbyte(newfile)

			Dim encryptionkey [size,size]

			fn$ = readLine(newfile)
			length = readInteger(newfile)
			file = OpenToWrite(fn$) 	
			
				enclocx=0
				enclocy=0
	
				for a=0 to length
					encryptionkey[enclocx,enclocy] = ReadByte(newfile)
					if (fn$<>filename$) 
							WriteByte(file, (ReadByte(newfile) ~~ encryptionkey[enclocx,enclocy]+a) ~~a)
					else
						print("ERROR: Bad " + filename$ + " AGM format")
						sync()
						sleep(4000)
						exitfunction
					endif
					inc enclocx
					if enclocx>size 
						enclocx=0
						inc enclocy
					endif
					if enclocy>size
						enclocx=0
						enclocy=0
					endif
		
		
				next
				ReadLine(newfile)
			CloseFile(file)
		else
//			print("ERROR: Bad " + filename$ + " AGM format")
	//		sync()
		//	sleep(4000)
			//exitfunction

		endif
	endwhile
	CloseFile(newfile)
endfunction


It will package almost any type of file up...you just require to add the code in for that type of file.. eg. if its a sound file etc


Example AGM included to be used with the decrypter

If need any support, give me a shout and ill help code it in

Enjoy folks!!
Posted: 1st Dec 2018 8:31
A pixelated noise shader could possibly be used for that pixel game while thinking perhaps a pause don't know I use a noise image
but the image makes no difference to how the shader will look so any will do

+ Code Snippet
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
 noise=LoadImage("noise.png") 
 
createShader()
spr=CreateSprite(noise)
SetSpriteSize(spr,1024,768)
shader=LoadSpriteShader("pixelize.ps")
SetSpriteShader( spr,shader )
SetShaderConstantByName( Shader,"mouse",0,0,0,0)
SetShaderConstantByName( shader,"iResolution",1024,768,0,0 )
do
	SetShaderConstantByName( Shader,"mouse",GetPointerX()/500,GetPointerY()/300,0,0)
    sync()  
loop
  
function createShader()

file = OpenToWrite("pixelize.ps")
WriteLine(file,"#ifdef GL_ES")
WriteLine(file,"precision mediump float;")
WriteLine(file,"#endif")
WriteLine(file,"#extension GL_OES_standard_derivatives : enable")
WriteLine(file,"uniform sampler2D texture0;")
WriteLine(file,"varying mediump vec2 uvVarying;")
WriteLine(file,"uniform float agk_time;")
WriteLine(file,"uniform vec2 mouse;")
WriteLine(file,"uniform vec2 iResolution;")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file,"vec2 i = floor(uvVarying.xy * 30.) + sin(agk_time);")
WriteLine(file,"gl_FragColor =vec4(mod(i.x * i.y + sin(agk_time),1.0 + mouse.x + sin(agk_time)));")
WriteLine(file,"}")
CloseFile(file)
endfunction


Edited fixed a silly error
Posted: 1st Dec 2018 10:25
@fubarpk Nice effect ....it looks like my TV doesn't work
Posted: 1st Dec 2018 20:56
Very nice. Might make a nice transition effect
Posted: 1st Dec 2018 21:10
Thanks Chafari and Blink

The transistion effect is a good idea perhaps while the world is built behind it
fading its alpha once the world is built


2D Waves Shader HAHAHA two ships sales the seas
+ Code Snippet
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
// noise=LoadImage("noise.png") 
 
shipSpr=createSprite(0)
SetSpritePosition(shipSpr,300,300)
SetSpriteColor(shipSpr,255,255,0,255)
SetSpriteSize(shipSpr,80,30) 
SetSpriteDepth(shipSpr,0)

shipSpr2=createSprite(0)
SetSpritePosition(shipSpr2,500,300)
SetSpriteColor(shipSpr2,0,255,255,255)
SetSpriteSize(shipSpr2,80,30) 
SetSpriteDepth(shipSpr2,0)

createShader()
waterSpr=CreateSprite(0)
SetSpriteSize(waterSpr,1024,768)
SetSpriteDepth(waterSpr,10)
shader=LoadSpriteShader("water.ps")
SetSpriteShader(waterSpr,shader)
SetShaderConstantByName( shader,"iResolution",1024,768,0,0 )
do
	x=getSpriteX(shipSpr):y=GetSpriteY(shipSpr)
	if pickColor(x+15,y+31)>55 
		SetSpritePosition(shipSpr,getSpriteX(shipSpr),GetSpriteY(shipSpr)-1)
	else
		SetSpritePosition(shipSpr,getSpriteX(shipSpr),GetSpriteY(shipSpr)+1)
	endif
	
	x2=getSpriteX(shipSpr2):y2=GetSpriteY(shipSpr2)
	if pickColor(x+15,y+31)>55 
		SetSpritePosition(shipSpr2,getSpriteX(shipSpr2),GetSpriteY(shipSpr2)-1)
	else
		SetSpritePosition(shipSpr2,getSpriteX(shipSpr2),GetSpriteY(shipSpr2)+1)
	endif
    sync()  
loop
  
function createShader()

file = OpenToWrite("water.ps")
WriteLine(file,"precision mediump float;")
WriteLine(file,"uniform float agk_time;")
WriteLine(file,"uniform vec2 iResolution;")
WriteLine(file,"uniform sampler2D texture0;")
WriteLine(file,"varying mediump vec2 uvVarying;")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file,"vec2 p = (gl_FragCoord.xy / iResolution.xy) - .5;")
//WriteLine(file,"float sx = 0.2 * (p.x * p.x * 6. - .6) * sin(69. * p.x - 4. * agk_time * .5);")
WriteLine(file,"float sx = 0.075 * (p.x * p.x * 6. - .6) * sin(39. * p.x - 4. * agk_time * .5);")
WriteLine(file,"gl_FragColor =vec4(.05, .0, (5. / (420. * abs(p.y - sx))), 1);")
WriteLine(file,"}")
CloseFile(file)
endfunction

Function pickColor(X,Y)
    local color,img 
    //color as integer
    rem prepare image grab area
    clearScreen()
    render()
    
    img = getImage(X,Y,X+1,Y+1)
    
    rem create memblock
       
    mem = createMemblockfromImage(img)
    
    rem get memblock data
    r = getMemblockbyte(mem,12):rem gets red channel data
    g = getMemblockbyte(mem,13):rem gets green channel data
    b = getMemblockbyte(mem,14):rem gets blue channel data
    
       
    rem tidy up
    deletememblock(mem)
    deleteimage(img)
    clearScreen()
    color = makeColor(r,g,b)
    color=r+g+b
endfunction b
Posted: 8th Dec 2018 22:30
Rubiks Cube Puzzle Game Creates all its own media and now has a json load/save feature

+ Code Snippet
// Project: RubiksCube 
// Created: 2018-12-08

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "RubiksCube" )
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

#constant KEY_SPACE        32
#constant KEY_LEFT         37
#constant KEY_UP           38
#constant KEY_RIGHT        39
#constant KEY_DOWN         40

#constant arrowLeft        1
#constant arrowRight       2
#constant arrowUp		   3
#constant arrowDown        4 
#constant solution         5 
  
#constant arrowLeftSpr1    1
#constant arrowLeftSpr2    2
#constant arrowLeftSpr3    3
#constant arrowRightSpr1   4
#constant arrowRightSpr2   5
#constant arrowRightSpr3   6
#constant arrowUpSpr1	   7
#constant arrowUpSpr2	   8
#constant arrowUpSpr3      9
#constant arrowDownSpr1    10 
#constant arrowDownSpr2    11 
#constant arrowDownSpr3    12 
#constant solutionSpr      13 
#constant loadBtn		   1
#constant saveBtn		   2
#constant shuffleBtn	   3 	

type cubePiece
	id as integer
	num as integer
	angleX as integer
	angleY as integer
	angleZ as integer
	x as integer
	y as integer
	z as integer
	startX as integer //used for checking if solved 
	startY as integer
	startZ as integer	
endtype 
	
global rubiks as cubePiece[27]
global solve as integer[100]
AddVirtualButton(loadBtn,895,290,75)
SetVirtualButtonColor(loadBtn,0,0,255)
SetVirtualButtonText(loadBtn,"Load")
AddVirtualButton(saveBtn,895,390,75)
SetVirtualButtonColor(saveBtn,0,0,255)
SetVirtualButtonText(saveBtn,"Save")
AddVirtualButton(shuffleBtn,895,490,75)
SetVirtualButtonColor(shuffleBtn,0,0,255)
SetVirtualButtonText(shuffleBtn,"Shufffle")


//front face start locations
rubiks[0].num=1:rubiks[0].x=-1:rubiks[0].y=1:rubiks[0].z=-1
rubiks[1].num=2:rubiks[1].x=0:rubiks[1].y=1:rubiks[1].z=-1
rubiks[2].num=3:rubiks[2].x=1:rubiks[2].y=1:rubiks[2].z=-1
rubiks[3].num=4:rubiks[3].x=-1:rubiks[3].y=0:rubiks[3].z=-1
rubiks[4].num=5:rubiks[4].x=0:rubiks[4].y=0:rubiks[4].z=-1
rubiks[5].num=6:rubiks[5].x=1:rubiks[5].y=0:rubiks[5].z=-1
rubiks[6].num=7:rubiks[6].x=-1:rubiks[6].y=-1:rubiks[6].z=-1
rubiks[7].num=8:rubiks[7].x=0:rubiks[7].y=-1:rubiks[7].z=-1
rubiks[8].num=9:rubiks[8].x=1:rubiks[8].y=-1:rubiks[8].z=-1

//middle start locations
rubiks[9].num=10:rubiks[9].x=-1:rubiks[9].y=1:rubiks[9].z=0
rubiks[10].num=11:rubiks[10].x=0:rubiks[10].y=1:rubiks[10].z=0
rubiks[11].num=12:rubiks[11].x=1:rubiks[11].y=1:rubiks[11].z=0
rubiks[12].num=13:rubiks[12].x=-1:rubiks[12].y=0:rubiks[12].z=0
rubiks[13].num=14:rubiks[13].x=0:rubiks[13].y=0:rubiks[13].z=0
rubiks[14].num=15:rubiks[14].x=1:rubiks[14].y=0:rubiks[14].z=0
rubiks[15].num=16:rubiks[15].x=-1:rubiks[15].y=-1:rubiks[15].z=0
rubiks[16].num=17:rubiks[16].x=0:rubiks[16].y=-1:rubiks[16].z=0
rubiks[17].num=18:rubiks[17].x=1:rubiks[17].y=-1:rubiks[17].z=0

//back start locations
rubiks[18].num=19:rubiks[18].x=-1:rubiks[18].y=1:rubiks[18].z=1
rubiks[19].num=20:rubiks[19].x=0:rubiks[19].y=1:rubiks[19].z=1
rubiks[20].num=21:rubiks[20].x=1:rubiks[20].y=1:rubiks[20].z=1
rubiks[21].num=22:rubiks[21].x=-1:rubiks[21].y=0:rubiks[21].z=1
rubiks[22].num=23:rubiks[22].x=0:rubiks[22].y=0:rubiks[22].z=1
rubiks[23].num=24:rubiks[23].x=1:rubiks[23].y=0:rubiks[23].z=1
rubiks[24].num=25:rubiks[24].x=-1:rubiks[24].y=-1:rubiks[24].z=1
rubiks[25].num=26:rubiks[25].x=0:rubiks[25].y=-1:rubiks[25].z=1
rubiks[26].num=27:rubiks[26].x=1:rubiks[26].y=-1:rubiks[26].z=1


triangle=createTriangleImage()
CreateSprite(arrowLeftSpr1,triangle):SetSpriteSize(arrowLeftSpr1,100,100):SetSpriteAngle(arrowLeftSpr1,-90)
CreateSprite(arrowLeftSpr2,triangle):SetSpriteSize(arrowLeftSpr2,100,100):SetSpriteAngle(arrowLeftSpr2,-90)
CreateSprite(arrowLeftSpr3,triangle):SetSpriteSize(arrowLeftSpr3,100,100):SetSpriteAngle(arrowLeftSpr3,-90)
CreateSprite(arrowRightSpr1,triangle):SetSpriteSize(arrowRightSpr1,100,100):SetSpriteAngle(arrowRightSpr1,90)
CreateSprite(arrowRightSpr2,triangle):SetSpriteSize(arrowRightSpr2,100,100):SetSpriteAngle(arrowRightSpr2,90)
CreateSprite(arrowRightSpr3,triangle):SetSpriteSize(arrowRightSpr3,100,100):SetSpriteAngle(arrowRightSpr3,90)
CreateSprite(arrowUpSpr1,triangle):SetSpriteSize(arrowUpSpr1,100,100)
CreateSprite(arrowUpSpr2,triangle):SetSpriteSize(arrowUpSpr2,100,100)
CreateSprite(arrowUpSpr3,triangle):SetSpriteSize(arrowUpSpr3,100,100)
CreateSprite(arrowDownSpr1,triangle):SetSpriteSize(arrowDownSpr1,100,100):SetSpriteAngle(arrowDownSpr1,180)
CreateSprite(arrowDownSpr2,triangle):SetSpriteSize(arrowDownSpr2,100,100):SetSpriteAngle(arrowDownSpr2,180)
CreateSprite(arrowDownSpr3,triangle):SetSpriteSize(arrowDownSpr3,100,100):SetSpriteAngle(arrowDownSpr3,180)
SetSpritePosition(arrowLeftSpr1,180,245)
SetSpritePosition(arrowLeftSpr2,180,345)
SetSpritePosition(arrowLeftSpr3,180,445)
SetSpritePosition(arrowRightSpr1,720,245)
SetSpritePosition(arrowRightSpr2,720,345)
SetSpritePosition(arrowRightSpr3,720,445)
SetSpritePosition(arrowUpSpr1,360,10)
SetSpritePosition(arrowUpSpr2,460,10)
SetSpritePosition(arrowUpSpr3,560,10)
SetSpritePosition(arrowDownSpr1,360,580)
SetSpritePosition(arrowDownSpr2,460,580)
SetSpritePosition(arrowDownSpr3,560,580)

createCubeObject()
obj=loadObject("Cube.obj")
img=createCubeTexture()

SetObjectImage(obj,img,0)
	
for num = 0 to 26
	rubiks[num].id=CloneObject(obj)
	SetObjectPosition(rubiks[num].id,rubiks[num].x,rubiks[num].y,rubiks[num].z)
	rubiks[num].startX=rubiks[num].x:rubiks[num].startY=rubiks[num].y:rubiks[num].startZ=rubiks[num].z
next
sync()
CreateSprite(solutionSpr,createSolvedImage())
SetSpriteSize(solutionSpr,418,446)
SetSpritePosition(solutionSpr,660,-150)
SetSpriteDepth(solutionSpr,11)
shuffle()
SetCameraPosition(1,0,3,-7)
do
	if ( GetPointerPressed ( ) = 1 )
        hit = GetSpriteHit(GetPointerX ( ), GetPointerY ( ) )
    endif
    
	If hit=arrowLeftSpr1//GetRawKeyState(KEY_Q)=1
		rotateTopRowAroundY() //:Sleep(250)
	endif	
	If hit=arrowLeftSpr2 //GetRawKeyState(KEY_A)=1
		rotateMiddleRowAroundY() //:Sleep(250) 
	endif	
	If hit=arrowLeftSpr3 //GetRawKeyState(KEY_Z)=1
		rotateBottomRowAroundY() //:Sleep(250)
	endif	
	
	If hit=arrowRightSpr1 //GetRawKeyState(KEY_W)=1
		rotate2TopRowAroundY() //:Sleep(250)
	endif	
	If hit=arrowRightSpr2 //GetRawKeyState(KEY_S)=1
		rotate2MiddleRowAroundY() //:Sleep(250)
	endif	
	If hit=arrowRightSpr3 //GetRawKeyState(KEY_X)=1
		rotate2BottomRowAroundY() //:Sleep(250)
	endif	
	
	If hit=arrowUpSpr1 //GetRawKeyState(KEY_E)=1
		rotateLeftColumaroundX() //:Sleep(250)
	endif
	If hit=arrowUpSpr2 //GetRawKeyState(KEY_R)=1
		rotateMiddleColumaroundX() //:Sleep(250)
	endif	
	If hit=arrowUpSpr3 //GetRawKeyState(KEY_T)=1
		rotateRightColumaroundX() //:Sleep(250)
	endif	
	
	If hit=arrowDownSpr1 //GetRawKeyState(KEY_D)=1
		rotate2LeftColumaroundX() //:Sleep(250)
	endif
	If hit=arrowDownSpr2 //GetRawKeyState(KEY_F)=1
		rotate2MiddleColumaroundX() //:Sleep(250)
	endif
	If hit=arrowDownSpr3 //GetRawKeyState(KEY_G)=1
		rotate2RightColumaroundX() //:Sleep(250)
	endif
	
	if GetVirtualButtonPressed(loadBtn)=1
		if GetFileExists("rubik.json")=1
			rubiks.load("rubik.json")
			for num = 0 to 26
				SetObjectPosition(rubiks[num].id,rubiks[num].x,rubiks[num].y,rubiks[num].z)
				SetObjectRotation(rubiks[num].id,rubiks[num].angleX,rubiks[num].angleY,rubiks[num].angleZ)
			next
		endif
    endif
	
	if GetVirtualButtonPressed(saveBtn)=1
		for num = 0 to 26
			rubiks[num].angleX=GetObjectAngleX(rubiks[num].id)
			rubiks[num].angleY=GetObjectAngleY(rubiks[num].id)
			rubiks[num].angleZ=GetObjectAngleZ(rubiks[num].id)
		next
        rubiks.save("rubik.json")        
    endif
    
    if GetRawKeyPressed(32)=1
		solve()
		sleep(100)
	endif	
    
	if GetVirtualButtonPressed(shuffleBtn)=1
		shuffle()
	endif
	hit=0
	
	Print( "RUBIKS CUBE PUZZLE" )
    Print( "Use the Arrow buttons" )
    Print( "to rotate cube pieces" )
    Print( "until it looks like ")
    Print( "the cube top right.")
    if isSolved() then Print("Solved")
    Sync()
loop


function getIdByLocation(x as integer,y as integer,z as integer)
	num=-1
	repeat
		inc num
	until rubiks[num].x=x and rubiks[num].y=y and rubiks[num].z=z
endfunction rubiks[num].id	

function setObjectNewlocation(id as integer,x as integer,y as integer,z as integer)
	num=-1
	repeat 
		inc num	
	until rubiks[num].id=id
	rubiks[num].x=x:rubiks[num].y=y:rubiks[num].z=z
	SetObjectPosition(rubiks[num].id,x,y,z)
endfunction	

function isSolved()
	num=-1:flag=1
	repeat
		inc num
		if rubiks[num].startX<>rubiks[num].x then flag=0
		if rubiks[num].startY<>rubiks[num].y then flag=0
		if rubiks[num].startZ<>rubiks[num].z then flag=0
	until num=26	
endfunction flag

function shuffle()
	for t = 1 to 100
	ran=(random(1,6))
	solve[t]=ran
	select ran
		case 1:
			rotateTopRowAroundY()
		endcase
		case 2:
			rotateMiddleRowAroundY()
		endcase
		case 3:
			rotateBottomRowAroundY()
		endcase
		case 4:
			rotateRightColumaroundX()
		endcase
		case 5:
			rotateMiddleColumaroundX()
		endcase
		case 6:
			rotateLeftColumaroundX()
		endcase
	endselect		
	next t			
endfunction

function solve()
	for t = 100 to 1 step -1
	ran=solve[t]
	select ran
		case 1:
			rotate2TopRowAroundY()
		endcase
		case 2:
			rotate2MiddleRowAroundY()
		endcase
		case 3:
			rotate2BottomRowAroundY()
		endcase
		case 4:
			rotate2RightColumaroundX()
		endcase
		case 5:
			rotate2MiddleColumaroundX()
		endcase
		case 6:
			rotate2LeftColumaroundX()
		endcase
	endselect
	sync():sleep(150)		
	next t			
endfunction


function rotateTopRowAroundY()
	id1=getIdByLocation(-1,1,-1) 
	id2=getIdByLocation(0,1,-1)  
	id3=getIdByLocation(1,1,-1)  
		
	id4=getIdByLocation(-1,1,0) 
	id5=getIdByLocation(0,1,0)  
	id6=getIdByLocation(1,1,0)  
		
	id7=getIdByLocation(-1,1,1) 
	id8=getIdByLocation(0,1,1)
	id9=getIdByLocation(1,1,1)  
		
	setObjectNewlocation(id1,-1,1,1):RotateObjectLocaly(id1,90)   
	setObjectNewlocation(id2,-1,1,0):RotateObjectLocaly(id2,90)  
	setObjectNewlocation(id3,-1,1,-1):RotateObjectLocaly(id3,90) 
		
	setObjectNewlocation(id4,0,1,1):RotateObjectLocaly(id4,90)   
	setObjectNewlocation(id5,0,1,0):RotateObjectLocaly(id5,90)   
	setObjectNewlocation(id6,0,1,-1):RotateObjectLocaly(id6,90)  
	
	setObjectNewlocation(id7,1,1,1):RotateObjectLocaly(id7,90)  
	setObjectNewlocation(id8,1,1,0):RotateObjectLocaly(id8,90)   
	setObjectNewlocation(id9,1,1,-1):RotateObjectLocaly(id9,90)  
endfunction	

function rotate2TopRowAroundY()
	id1=getIdByLocation(-1,1,-1) 
	id2=getIdByLocation(0,1,-1)  
	id3=getIdByLocation(1,1,-1)  
		
	id4=getIdByLocation(-1,1,0) 
	id5=getIdByLocation(0,1,0)  
	id6=getIdByLocation(1,1,0)  
		
	id7=getIdByLocation(-1,1,1) 
	id8=getIdByLocation(0,1,1)
	id9=getIdByLocation(1,1,1)  
		
	setObjectNewlocation(id1,1,1,-1):RotateObjectLocaly(id1,-90)   
	setObjectNewlocation(id2,1,1,0):RotateObjectLocaly(id2,-90)  
	setObjectNewlocation(id3,1,1,1):RotateObjectLocaly(id3,-90) 
		
	setObjectNewlocation(id4,0,1,-1):RotateObjectLocaly(id4,-90)   
	setObjectNewlocation(id5,0,1,0):RotateObjectLocaly(id5,-90)   
	setObjectNewlocation(id6,0,1,1):RotateObjectLocaly(id6,-90)  
	
	setObjectNewlocation(id7,-1,1,-1):RotateObjectLocaly(id7,-90)  
	setObjectNewlocation(id8,-1,1,0):RotateObjectLocaly(id8,-90)   
	setObjectNewlocation(id9,-1,1,1):RotateObjectLocaly(id9,-90)  
endfunction	

function rotateMiddleRowAroundY()
	id1=getIdByLocation(-1,0,-1) 
	id2=getIdByLocation(0,0,-1)  
	id3=getIdByLocation(1,0,-1)  
		
	id4=getIdByLocation(-1,0,0) 
	id5=getIdByLocation(0,0,0)  
	id6=getIdByLocation(1,0,0)  
		
	id7=getIdByLocation(-1,0,1) 
	id8=getIdByLocation(0,0,1)
	id9=getIdByLocation(1,0,1)  
		
	setObjectNewlocation(id1,-1,0,1):RotateObjectLocaly(id1,90)   
	setObjectNewlocation(id2,-1,0,0):RotateObjectLocaly(id2,90)  
	setObjectNewlocation(id3,-1,0,-1):RotateObjectLocaly(id3,90) 
		
	setObjectNewlocation(id4,0,0,1):RotateObjectLocaly(id4,90)   
	setObjectNewlocation(id5,0,0,0):RotateObjectLocaly(id5,90)   
	setObjectNewlocation(id6,0,0,-1):RotateObjectLocaly(id6,90)  
		
	setObjectNewlocation(id7,1,0,1):RotateObjectLocaly(id7,90)  
	setObjectNewlocation(id8,1,0,0):RotateObjectLocaly(id8,90)   
	setObjectNewlocation(id9,1,0,-1):RotateObjectLocaly(id9,90)
endfunction	

function rotate2MiddleRowAroundY()
	id1=getIdByLocation(-1,0,-1) 
	id2=getIdByLocation(0,0,-1)  
	id3=getIdByLocation(1,0,-1)  
		
	id4=getIdByLocation(-1,0,0) 
	id5=getIdByLocation(0,0,0)  
	id6=getIdByLocation(1,0,0)  
		
	id7=getIdByLocation(-1,0,1) 
	id8=getIdByLocation(0,0,1)
	id9=getIdByLocation(1,0,1)  
		
	setObjectNewlocation(id1,1,0,-1):RotateObjectLocaly(id1,-90)   
	setObjectNewlocation(id2,1,0,0):RotateObjectLocaly(id2,-90)  
	setObjectNewlocation(id3,1,0,1):RotateObjectLocaly(id3,-90) 
		
	setObjectNewlocation(id4,0,0,-1):RotateObjectLocaly(id4,-90)   
	setObjectNewlocation(id5,0,0,0):RotateObjectLocaly(id5,-90)   
	setObjectNewlocation(id6,0,0,1):RotateObjectLocaly(id6,-90)  
	
	setObjectNewlocation(id7,-1,0,-1):RotateObjectLocaly(id7,-90)  
	setObjectNewlocation(id8,-1,0,0):RotateObjectLocaly(id8,-90)   
	setObjectNewlocation(id9,-1,0,1):RotateObjectLocaly(id9,-90) 
endfunction	

function rotate2BottomRowAroundY()
	id1=getIdByLocation(-1,-1,-1) 
	id2=getIdByLocation(0,-1,-1)  
	id3=getIdByLocation(1,-1,-1)  
		
	id4=getIdByLocation(-1,-1,0) 
	id5=getIdByLocation(0,-1,0)  
	id6=getIdByLocation(1,-1,0)  
		
	id7=getIdByLocation(-1,-1,1) 
	id8=getIdByLocation(0,-1,1)
	id9=getIdByLocation(1,-1,1)  
		
	setObjectNewlocation(id1,1,-1,-1):RotateObjectLocaly(id1,-90)   
	setObjectNewlocation(id2,1,-1,0):RotateObjectLocaly(id2,-90)  
	setObjectNewlocation(id3,1,-1,1):RotateObjectLocaly(id3,-90) 
		
	setObjectNewlocation(id4,0,-1,-1):RotateObjectLocaly(id4,-90)   
	setObjectNewlocation(id5,0,-1,0):RotateObjectLocaly(id5,-90)   
	setObjectNewlocation(id6,0,-1,1):RotateObjectLocaly(id6,-90)  
	
	setObjectNewlocation(id7,-1,-1,-1):RotateObjectLocaly(id7,-90)  
	setObjectNewlocation(id8,-1,-1,0):RotateObjectLocaly(id8,-90)   
	setObjectNewlocation(id9,-1,-1,1):RotateObjectLocaly(id9,-90) 
endfunction


function rotateBottomRowAroundY()
	id1=getIdByLocation(-1,-1,-1) 
	id2=getIdByLocation(0,-1,-1)  
	id3=getIdByLocation(1,-1,-1)  
		
	id4=getIdByLocation(-1,-1,0) 
	id5=getIdByLocation(0,-1,0)  
	id6=getIdByLocation(1,-1,0)  
		
	id7=getIdByLocation(-1,-1,1) 
	id8=getIdByLocation(0,-1,1)
	id9=getIdByLocation(1,-1,1)  
		
	setObjectNewlocation(id1,-1,-1,1):RotateObjectLocaly(id1,90)   
	setObjectNewlocation(id2,-1,-1,0):RotateObjectLocaly(id2,90)  
	setObjectNewlocation(id3,-1,-1,-1):RotateObjectLocaly(id3,90) 
		
	setObjectNewlocation(id4,0,-1,1):RotateObjectLocaly(id4,90)   
	setObjectNewlocation(id5,0,-1,0):RotateObjectLocaly(id5,90)   
	setObjectNewlocation(id6,0,-1,-1):RotateObjectLocaly(id6,90)  
		
	setObjectNewlocation(id7,1,-1,1):RotateObjectLocaly(id7,90)  
	setObjectNewlocation(id8,1,-1,0):RotateObjectLocaly(id8,90)   
	setObjectNewlocation(id9,1,-1,-1):RotateObjectLocaly(id9,90)  
endfunction	

function rotateRightColumaroundX()
	id3=getIdByLocation(1,1,-1) 
	id6=getIdByLocation(1,0,-1)  
	id9=getIdByLocation(1,-1,-1)  
		
	id12=getIdByLocation(1,1,0) 
	id15=getIdByLocation(1,0,0)  
	id18=getIdByLocation(1,-1,0)  
		
	id21=getIdByLocation(1,1,1) 
	id24=getIdByLocation(1,0,1)
	id27=getIdByLocation(1,-1,1)  
		
	setObjectNewlocation(id3,1,1,1):RotateObjectLocalX(id3,90)   
	setObjectNewlocation(id6,1,1,0):RotateObjectLocalX(id6,90)  
	setObjectNewlocation(id9,1,1,-1):RotateObjectLocalX(id9,90) 
		
	setObjectNewlocation(id12,1,0,1):RotateObjectLocalX(id12,90)   
	setObjectNewlocation(id15,1,0,0):RotateObjectLocalX(id15,90)   
	setObjectNewlocation(id18,1,0,-1):RotateObjectLocalX(id18,90)  
		
	setObjectNewlocation(id21,1,-1,1):RotateObjectLocalX(id21,90)  
	setObjectNewlocation(id24,1,-1,0):RotateObjectLocalX(id24,90)   
	setObjectNewlocation(id27,1,-1,-1):RotateObjectLocalX(id27,90)  
endfunction

function rotate2RightColumaroundX()
	id3=getIdByLocation(1,1,-1) 
	id6=getIdByLocation(1,0,-1)  
	id9=getIdByLocation(1,-1,-1)  
		
	id12=getIdByLocation(1,1,0) 
	id15=getIdByLocation(1,0,0)  
	id18=getIdByLocation(1,-1,0)  
		
	id21=getIdByLocation(1,1,1) 
	id24=getIdByLocation(1,0,1)
	id27=getIdByLocation(1,-1,1)  
		
	setObjectNewlocation(id3,1,-1,-1):RotateObjectLocalX(id3,-90)   
	setObjectNewlocation(id6,1,-1,0):RotateObjectLocalX(id6,-90)  
	setObjectNewlocation(id9,1,-1,1):RotateObjectLocalX(id9,-90) 
		
	setObjectNewlocation(id12,1,0,-1):RotateObjectLocalX(id12,-90)   
	setObjectNewlocation(id15,1,0,0):RotateObjectLocalX(id15,-90)   
	setObjectNewlocation(id18,1,0,1):RotateObjectLocalX(id18,-90)  
		
	setObjectNewlocation(id21,1,1,-1):RotateObjectLocalX(id21,-90)  
	setObjectNewlocation(id24,1,1,0):RotateObjectLocalX(id24,-90)   
	setObjectNewlocation(id27,1,1,1):RotateObjectLocalX(id27,-90)  
endfunction


function rotateMiddleColumaroundX()
	id3=getIdByLocation(0,1,-1) 
	id6=getIdByLocation(0,0,-1)  
	id9=getIdByLocation(0,-1,-1)  
		
	id12=getIdByLocation(0,1,0) 
	id15=getIdByLocation(0,0,0)  
	id18=getIdByLocation(0,-1,0)  
		
	id21=getIdByLocation(0,1,1) 
	id24=getIdByLocation(0,0,1)
	id27=getIdByLocation(0,-1,1)  
		
	setObjectNewlocation(id3,0,1,1):RotateObjectLocalX(id3,90)   
	setObjectNewlocation(id6,0,1,0):RotateObjectLocalX(id6,90)  
	setObjectNewlocation(id9,0,1,-1):RotateObjectLocalX(id9,90) 
		
	setObjectNewlocation(id12,0,0,1):RotateObjectLocalX(id12,90)   
	setObjectNewlocation(id15,0,0,0):RotateObjectLocalX(id15,90)   
	setObjectNewlocation(id18,0,0,-1):RotateObjectLocalX(id18,90)  
		
	setObjectNewlocation(id21,0,-1,1):RotateObjectLocalX(id21,90)  
	setObjectNewlocation(id24,0,-1,0):RotateObjectLocalX(id24,90)   
	setObjectNewlocation(id27,0,-1,-1):RotateObjectLocalX(id27,90)  
endfunction
	
function rotate2MiddleColumaroundX()
	id3=getIdByLocation(0,1,-1) 
	id6=getIdByLocation(0,0,-1)  
	id9=getIdByLocation(0,-1,-1)  
		
	id12=getIdByLocation(0,1,0) 
	id15=getIdByLocation(0,0,0)  
	id18=getIdByLocation(0,-1,0)  
		
	id21=getIdByLocation(0,1,1) 
	id24=getIdByLocation(0,0,1)
	id27=getIdByLocation(0,-1,1)  
		
	setObjectNewlocation(id3,0,-1,-1):RotateObjectLocalX(id3,-90)   
	setObjectNewlocation(id6,0,-1,0):RotateObjectLocalX(id6,-90)  
	setObjectNewlocation(id9,0,-1,1):RotateObjectLocalX(id9,-90) 
		
	setObjectNewlocation(id12,0,0,-1):RotateObjectLocalX(id12,-90)   
	setObjectNewlocation(id15,0,0,0):RotateObjectLocalX(id15,-90)   
	setObjectNewlocation(id18,0,0,1):RotateObjectLocalX(id18,-90)  
		
	setObjectNewlocation(id21,0,1,-1):RotateObjectLocalX(id21,-90)  
	setObjectNewlocation(id24,0,1,0):RotateObjectLocalX(id24,-90)   
	setObjectNewlocation(id27,0,1,1):RotateObjectLocalX(id27,-90)  
endfunction	

function rotateLeftColumaroundX()
	id3=getIdByLocation(-1,1,-1) 
	id6=getIdByLocation(-1,0,-1)  
	id9=getIdByLocation(-1,-1,-1)  
		
	id12=getIdByLocation(-1,1,0) 
	id15=getIdByLocation(-1,0,0)  
	id18=getIdByLocation(-1,-1,0)  
		
	id21=getIdByLocation(-1,1,1) 
	id24=getIdByLocation(-1,0,1)
	id27=getIdByLocation(-1,-1,1)  
		
	setObjectNewlocation(id3,-1,1,1):RotateObjectLocalX(id3,90)   
	setObjectNewlocation(id6,-1,1,0):RotateObjectLocalX(id6,90)  
	setObjectNewlocation(id9,-1,1,-1):RotateObjectLocalX(id9,90) 
		
	setObjectNewlocation(id12,-1,0,1):RotateObjectLocalX(id12,90)   
	setObjectNewlocation(id15,-1,0,0):RotateObjectLocalX(id15,90)   
	setObjectNewlocation(id18,-1,0,-1):RotateObjectLocalX(id18,90)  
		
	setObjectNewlocation(id21,-1,-1,1):RotateObjectLocalX(id21,90)  
	setObjectNewlocation(id24,-1,-1,0):RotateObjectLocalX(id24,90)   
	setObjectNewlocation(id27,-1,-1,-1):RotateObjectLocalX(id27,90)  	
endfunction

function rotate2LeftColumaroundX()
	id3=getIdByLocation(-1,1,-1) 
	id6=getIdByLocation(-1,0,-1)  
	id9=getIdByLocation(-1,-1,-1)  
		
	id12=getIdByLocation(-1,1,0) 
	id15=getIdByLocation(-1,0,0)  
	id18=getIdByLocation(-1,-1,0)  
		
	id21=getIdByLocation(-1,1,1) 
	id24=getIdByLocation(-1,0,1)
	id27=getIdByLocation(-1,-1,1)  
		
	setObjectNewlocation(id3,-1,-1,-1):RotateObjectLocalX(id3,-90)   
	setObjectNewlocation(id6,-1,-1,0):RotateObjectLocalX(id6,-90)  
	setObjectNewlocation(id9,-1,-1,1):RotateObjectLocalX(id9,-90) 
		
	setObjectNewlocation(id12,-1,0,-1):RotateObjectLocalX(id12,-90)   
	setObjectNewlocation(id15,-1,0,0):RotateObjectLocalX(id15,-90)   
	setObjectNewlocation(id18,-1,0,1):RotateObjectLocalX(id18,-90)  
		
	setObjectNewlocation(id21,-1,1,-1):RotateObjectLocalX(id21,-90)  
	setObjectNewlocation(id24,-1,1,0):RotateObjectLocalX(id24,-90)   
	setObjectNewlocation(id27,-1,1,1):RotateObjectLocalX(id27,-90) 
endfunction	

Function createCubeObject()
	file = OpenToWrite("cube.obj")
	WriteLine(file,"o Default")
	WriteLine(file,"v 0.475000 0.475000 -0.475000")
	WriteLine(file,"v -0.475000 -0.475000 -0.475000")
	WriteLine(file,"v -0.475000 0.475000 -0.475000")
	WriteLine(file,"v 0.475000 -0.475000 -0.475000")
	WriteLine(file,"v 0.475000 -0.475000 0.475000")
	WriteLine(file,"v -0.475000 -0.475000 0.475000")
	WriteLine(file,"v -0.475000 0.475000 0.475000")
	WriteLine(file,"v 0.475000 0.475000 0.475000")
	WriteLine(file,"vt 0.333333 0.333333")
	WriteLine(file,"vt 0.666667 0.000000")
	WriteLine(file,"vt 0.666667 0.333333")
	WriteLine(file,"vt 0.333333 0.000000")
	WriteLine(file,"vt 0.331333 1.000000")
	WriteLine(file,"vt 0.000000 0.668667")
	WriteLine(file,"vt 0.331333 0.668667")
	WriteLine(file,"vt 0.000000 1.000000")
	WriteLine(file,"vt 1.000000 0.333333")
	WriteLine(file,"vt 0.666667 0.666667")
	WriteLine(file,"vt 1.000000 0.666667")
	WriteLine(file,"vt 0.333333 0.666667")
	WriteLine(file,"vt 0.333333 1.000000")
	WriteLine(file,"vt 0.666667 1.000000")
	WriteLine(file,"vt 0.000000 0.666667")
	WriteLine(file,"vt 0.000000 0.333333")
	WriteLine(file,"vn 0.5774 0.5774 -0.5774")
	WriteLine(file,"vn -0.5774 -0.5774 -0.5774")
	WriteLine(file,"vn -0.5774 0.5774 -0.5774")
	WriteLine(file,"vn 0.5774 -0.5774 -0.5774")
	WriteLine(file,"vn 0.5774 -0.5774 0.5774")
	WriteLine(file,"vn -0.5774 -0.5774 0.5774")
	WriteLine(file,"vn -0.5774 0.5774 0.5774")
	WriteLine(file,"vn 0.5774 0.5774 0.5774")
	
	WriteLine(file,"s 1")
	WriteLine(file,"f 1/1/1 2/2/2 3/3/3")
	WriteLine(file,"f 4/4/4 2/2/2 1/1/1")
	WriteLine(file,"f 2/5/2 5/6/5 6/7/6")
	WriteLine(file,"f 4/8/4 5/6/5 2/5/2")
	WriteLine(file,"f 2/9/2 7/10/7 3/3/3")
	WriteLine(file,"f 6/11/6 7/10/7 2/9/2")
	WriteLine(file,"f 7/10/7 8/12/8 1/1/1")
	WriteLine(file,"f 3/3/3 7/10/7 1/1/1")
	WriteLine(file,"f 5/13/5 7/10/7 6/14/6")
	WriteLine(file,"f 5/13/5 8/12/8 7/10/7")
	WriteLine(file,"f 1/1/1 8/12/8 5/15/5")
	WriteLine(file,"f 1/1/1 5/15/5 4/16/4")
	CloseFile(file)
endfunction	

function createCubeTexture()
	yellow=makecolor(255,255,0) 	//yellow
	blue=makecolor(0,0,255)   		//blue
	white=makecolor(255,255,255) 	//white
	red=makecolor(255,0,0)     		//red
	green=makecolor(0,255,0)     	//green
	orange=makecolor(255,165,0)   	//orange
		
	ClearScreen()
	Sync()
	drawbox(0,0,519,519,white,white,white,white,1) 	
	
	drawBox(0,0,170,170,yellow,yellow,yellow,yellow,1)	
	drawBox(170,0,340,170,blue,blue,blue,blue,1)	
	drawbox(20,0,29,9,white,white,white,white,1)
	drawbox(0,171,170,341,red,red,red,red,1)
	drawbox(170,171,340,341,green,green,green,green,1)
	drawbox(341,171,511,341,orange,orange,orange,orange,1)
	Render()
	img = getImage(0,0,511,511)
endfunction	img

function createTriangleImage()
    rem draw a triangle image used for the player sprite on radar
    green=makecolor(0,255,0)     	//green
    SetClearColor(0,0,0)
    ClearScreen()
    Render()
    DrawLine(50,0,100,100,green,green)
    DrawLine(50,0,0,100,green,green)
    DrawLine(0,100,100,100,green,green)
    //DrawLine(5,0,5,9,green,green)
      
    //draw these if you want it filled
    //DrawLine(4,0,8,9,green,green)
    //DrawLine(0,9,8,9,green,green)
    //DrawLine(0,9,4,0,green,green)   
    //DrawBox(4,1,6,8,green,green,green,green,1)
      
    swap()
    img = getimage(1,1,100,100)
    SetImageTransparentColor(img,0,0,0)
endfunction img
 
 
function createSolvedImage()
	SetClearColor(0,0,0)
    ClearScreen()
    Render()
    for num = 0 to 26
		DrawObject(rubiks[num].id)
    next num
	render()
    //swap()
    img=GetImage(292,122,418,446)
    SetImageTransparentColor(img,0,0,0)
endfunction	 img
Posted: 8th Dec 2018 22:34
niiiiiiiiiiiice - good works as usual
Posted: 9th Dec 2018 6:46
Thanks puzzler
Posted: 9th Dec 2018 15:26
@fubarpk Nice one ! I hade to put some sleep here and there to have control . You could make a system to work with Mouseclick over row and columns . I remember when I could resolve it long long ago