Hi
I have tried this code to add isometric block.
It works fine, but in some cases, the block isn't added at the position of the mouse.
Do you know how I can fixe that ?
// Project: iso_grid
// Created: 2017-05-29
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "iso_grid" )
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
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 tObject
x as integer
y as integer
Sprite as integer
endtype
Global dim object[] as tobject
Loadimage(1,"block.png")
do
Print("left clic to add a block / right clic to delete the block")
if GetRawMouseLeftState()
tx = ScreenToWorldX(getpointerx())
ty = ScreenToWorldy(getpointery())
x = tx/64 + ty/46
y = (ty/23 - tx/32)/2
find= 0
For i=0 to object.length
if x = object[i].x and y = object[i].y
find =1
exit
endif
next
if find = 0
object.length = object.length +1
j = object.length
Object[j].x = x
Object[j].y = y
Object[j].sprite = CreateSprite(1)
tx = (x-y)*32
ty = (x+y)*23
SetSpriteposition(object[j].sprite,tx,ty)
endif
endif
// clic to add an object
if GetRawMouserightState()
tx = ScreenToWorldX(getpointerx())
ty = ScreenToWorldy(getpointery())
x = tx/64 + ty/46
y = (ty/23 - tx/32)/2
find= 0
For i=0 to object.length
if x = object[i].x and y = object[i].y
DeleteSprite(Object[i].sprite)
object.remove(i)
exit
endif
next
endif
Print( ScreenFPS() )
Sync()
loop
Image :
http://blendman.free.fr/dev/agk/block.png
AGK2 tier1 - http://www.dracaena-studio.com