howdy,
Webdext was the one who helped me so the information panel for sprites by dynamically assigning an iamge to a sprite
used specifically for the info and above all the rest
KEvil cre helped me with the drag n drop component as I couldnt work out one aspect of it.
thats a bonus u get since its part of this snippet.
` ---------------------------------
` drag and drop sprite function 4
` indi feb 2002
` snap to hotspot help by kevilcre
` text info sprite help by Webdext
` ---------------------------------
` temp setup
cls
sync rate 0
sync on
randomize timer()
set text font "verdana"
set text size 12
`dim debug_message$(1)
`debug_message$(1) = "noevent"
` ------------------------------------------
` hot spots
gen_temp_img(155,155,155,1,10,"h")
dim hotspot_spr_area(10)
dim hotspot_spr_center(10)
for i = 1 to 10
hotspot_spr_area(i) = 32
hotspot_spr_center(i) = 16
next i
dim hotspot_sprx(10)
dim hotspot_spry(10)
for i = 1 to 10
hotspot_sprx(i) = 10
hotspot_spry(i) = i*35
sprite i,hotspot_sprx(i),hotspot_spry(i),i
next i
` ------------------------------------------
` sprites
gen_temp_img(255,255,25,11,20,"s")
` sprite mass and size details
dim spr_area(20)
dim spr_center(20)
for i = 11 to 20
spr_area(i) = 32
spr_center(i) = 16
next i
` display intial location
dim sprx(20)
dim spry(20)
for i = 11 to 20
sprx(i) = 100
spry(i) = i*35 - 300
sprite i,sprx(i),spry(i),i
next i
` temp 3d effect
make matrix 1,100,100,10,10
backdrop on
color backdrop 0
` setup text ink
ink rgb(255,255,255),1
`initialize transparent box
init(1)
` temp main loop
do
` function in use
if sprite exist(50000)=1 then hide sprite 50000
for i = 11 to 20
drag_sprite(i)
next i
show_sprite_btn(400,10,450,30)
`text 10,10,debug_message$(1)
sync
loop
`--------------------------------------------------------
` A drag and Drop sprite by indi feb 2002
` Kevilcre's help with snap to hotspot sprite
`
`
`--------------------------------------------------------
function drag_sprite(spritenum)
if mousex() > sprx(spritenum) and mousex() < sprx(spritenum) + sprite width(spritenum) and mousey() > spry(spritenum) and mousey() < spry(spritenum) + sprite height(spritenum)
displayInfo(1, 50000, spritenum)
show sprite 50000
endif
if mouseclick() = 1 and mousex() > sprx(spritenum) and mousex() < sprx(spritenum) + sprite width(spritenum) and mousey() > spry(spritenum) and mousey() < spry(spritenum) + sprite height(spritenum)
repeat
sprite spritenum,mousex()-spr_center(spritenum),mousey()-spr_center(spritenum),spritenum : sync
until mouseclick() = 0
` snapping sprite options
` SNAP TO ANY HOT SPOT
` for i= 1 to 10
` if mousex()>hotspot_sprx(i) and mousex()<hotspot_sprx(i)+hotspot_spr_area(i) and mousey()>hotspot_spry(i) and mousey()<hotspot_spry(i)+hotspot_spr_area(i)
` sprx(spritenum) = hotspot_sprx(i)
` spry(spritenum) = hotspot_spry(i)
` sprite spritenum,sprx(spritenum),spry(spritenum),spritenum
`
` exitfunction
` endif
` next i
` SNAP TO ONE HOTPSOT
for i= 1 to 10
if mousex()>hotspot_sprx(i) and mousex()<hotspot_sprx(i)+hotspot_spr_area(i) and mousey()>hotspot_spry(i) and mousey()<hotspot_spry(i)+hotspot_spr_area(i)
spr_col = sprite collision(i+10,i)
if spr_col = 1
sprx(i+10) = hotspot_sprx(i)
spry(i+10) = hotspot_spry(i)
sprite i + 10,sprx(i + 10),spry(i + 10),i + 10
exitfunction
endif
endif
next i
sprx(spritenum) = mousex()-spr_center(spritenum)
spry(spritenum) = mousey()-spr_center(spritenum)
endif
endfunction
`--------------------------------------------------------
`--------------------------------------------------------
`
`display sprite name
`
`--------------------------------------------------------
function show_sprite_btn(x1,y1,x2,y2)
ink rgb(120,120,120),1
box x1,y1,x2,y2
ink rgb(200,200,200),1
text x1+5,y1+5,"reset"
if mousex()>x1 and mousex()<x2
if mousey()>y1 and mousey()<y2
if mouseclick()=1
show_all_sprites(11,20)
dim sprx(20)
dim spry(20)
for i = 11 to 20
sprx(i) = 100
spry(i) = i*35 - 300
sprite i,sprx(i),spry(i),i
next i
endif
endif
endif
endfunction
` show and hide sprite functions
function show_all_sprites(min,max)
for x = min to max
show sprite x
next x
endfunction
function hide_all_sprites(min,max)
for x = min to max
hide sprite x
next x
endfunction
function gen_temp_img(r,g,b,min,max,d$)
` make some temp squares
cls
for i = min to max
ink rgb(r,g,b),1
box 0,0,32,32
ink rgb(30,30,30),1
text 3,3,d$+STR$(i)
get image i,0,0,32,32
next i
cls
endfunction
Function init(bitmap)
`Create bitmap to use as text buffer
Create Bitmap bitmap, 400, 400
Set Current Bitmap bitmap
cls RGB(40,40,150)
` Cls
`Create transparent image
` For y = 0 to 400
` For x = 0 to 400
` c = 1 - c
` If c
` Dot x, y
` EndIf
` Next x
` Next y
Get Image 50001,0,0,400,400
Set Current Bitmap 0
EndFunction
Function displayInfo(bitmap, img, spriteNum)
Set Current Bitmap bitmap
Cls
Paste image 50001, 0,0
`Create array of text lines for ease of programming
textLineCount = 10
Dim TextLine$(10)
`TODO: Your code goes here to fill in lines of code with data
TextLine$(0) = "item name :" + STR$(spritenum)
TextLine$(1) = "item display mod 1"
TextLine$(2) = "item display mod 2"
TextLine$(3) = "item display mod 3"
TextLine$(4) = "item display mod 4"
TextLine$(5) = "item display mod 5"
TextLine$(6) = "item display mod 6"
TextLine$(7) = "item display mod 7"
TextLine$(8) = "item display mod 8"
TextLine$(9) = "item display mod 9"
`Get longest line width
best = len(TextLine$(0))
for i = 1 to textLineCount - 1
curr = len(TextLine$(0))
If curr > best then best = curr
next i
imageWidth = 20 + best * 8
imageHeight = 20 + textLineCount * 14
if imageWidth > 400 then imageWidth = 400
`Draw text to text buffer
For i = 0 to textLineCount - 1
ink RGB(12,12,12), 0
Text 11, 11 + (i * 14), TextLine$( i)
Text 12, 11 + (i * 14), TextLine$( i)
ink RGB(255,255,255), 0
Text 10, 10 + (i * 14), TextLine$( i)
Next i
ink RGB(255,255,255), 0
Line 0, 0, imageWidth-1, 0
Line 0, 0, 0, imageHeight-1
Line imageWidth-1, 0,imageWidth-1,imageHeight-1
Line 0, imageHeight-1,imageWidth-1,imageHeight-1
Get Image img,0,0,imageWidth,imageHeight
Set Current bitmap 0
dsx = sprx(spritenum) + spr_center(20) -32
dsy = spry(spritenum) + spr_area(20) + 3
Sprite 50000, dsx, dsy, img
EndFunction
` ------------------------------------------------
` new inbuilt mouse graphics for sprite 65000
` gen_simple_mouse_gfx()
function gen_simple_mouse_gfx()
` mouse image 1 dormant
ink rgb(0,200,0),1
for i = 1 to 16
box i+1,i+1,i+i,i+i
next i
ink rgb(0,155,0),1
box 12,12,16,16
get image 65001,0,0,16,16
` mouse image 2
ink rgb(255,255,0),1
for i = 1 to 16
box i+1,i+1,i+i,i+i
next i
ink rgb(155,155,0),1
box 12,12,16,16
get image 65002,0,0,16,16
` mouse image 3
ink rgb(255,0,0),1
for i = 1 to 16
box i+1,i+1,i+i,i+i
next i
ink rgb(155,155,0),1
box 12,12,16,16
get image 65003,0,0,16,16
cls rgb(0,0,0)
endfunction
` ------------------------------------------------