Hello all,
I am trying to make my own editor. I am using sprites that are 88x88. So I created a background grid and loaded it with sprites.
I can move around by pressing the arrow keys and I can even change my image by pressing the a key.
But if I press the space bar, to place my sprite it changes a total of six sprites.
from the images I have my sprite at x=441 and y=265 when I hit space it makes the 6 blocks change.
My code at the bottom in the //place block image is where I am trying to change the images.
Any help, I am pulling out my hair on this.
Thanks
-Brian
//Editor
sp as integer
yp as integer
blockimage as integer
underblock as integer
blockimage=502
joyx=1
joyy=1
SetVirtualResolution(3000,1024)
UseNewDefaultFonts( 1 )
//load background
LoadImage(500,"BGL1-grid.png")
CreateSprite(500,500)
SetSpritePosition(500,0,0)
SetJoystickScreenPosition(500,350,100)
// play blocks
LoadImage(502,"2.png")
LoadImage(503,"3.png")
LoadImage(504,"4.png")
LoadImage(505,"5.png")
LoadImage(506,"6.png")
LoadImage(507,"7.png")
LoadImage(508,"8.png")
LoadImage(509,"9.png")
LoadImage(510,"10.png")
LoadImage(511,"11.png")
LoadImage(512,"12.png")
LoadImage(513,"13.png")
LoadImage(514,"14.png")
LoadImage(515,"15.png")
LoadImage(516,"16.png")
LoadImage(517,"17.png")
LoadImage(518,"18.png")
CreateSprite(502,502)
SetSpritePosition(502,0,0)
//load blank sprites
for a=1 to 408
LoadImage(a,"button.png")
CreateSprite(a,a)
next a
//place blank sprites
for b=1 to 12
for a=1 to 2905 step 88
SetSpritePosition(sp,a,yp)
inc sp
sync()
next a
yp=yp+88
next b
do
//move player left
If GetRawKeyState(37)
joyx=joyx-88
sleep(250)
EndIf
//move player right
If GetRawKeyState(39)
joyx=joyx+88
sleep(250)
EndIf
//move player up
If GetRawKeyState(38)
joyy=joyy-88
sleep(250)
EndIf
//move player down
If GetRawKeyState(40)
joyy=joyy+88
sleep(250)
EndIf
SetSpritePosition(502,joyx,joyy)
if joyx<1 then joyx=1 //far left of screen
if joyy<1 then joyy=1 // top of screen
if joyx>3000 then joyx=3000 // far right of screen
//make position text
CreateText(503, "name")
SetTextString(503,"X="+str(joyx))
SetTextSize(503,40)
SetTextPosition(503,1,1)
SetTextColor(503,0,0,0,255)
CreateText(504, "name")
SetTextString(504,"Y="+str(joyy))
SetTextSize(504,40)
SetTextPosition(504,1,88)
SetTextColor(504,0,0,0,255)
//change block image
If GetRawKeyState(65)
SetSpriteImage(502,blockimage)
inc blockimage
if blockimage>518 then blockimage=502
sleep(250)
EndIf
//place block image
If GetRawKeyState(32)
for a=1 to 408
if GetSpriteCollision(a,502) then SetSpriteImage(a,502)
next a
EndIf
Sync()
loop