Code: Select all
include, plotscr.hsd
include, ShowMe.hsi
include, Scancode.hsi
#----------------------------------------------------------------------------
global variable, begin
1, cx
2, cy
3, attackcol
4, attacksl
5, playing
end
#----------------------------------------------------------------------------
plotscript, main, begin #set as new game script
runalways
end
#----------------------------------------------------------------------------
plotscript, atk, begin
if (key is pressed(key:w)) then (
set slice velocity y (sli:Attack,10)
show value (0) #debugging purposes
)
if (key is pressed(key:s)) then (
set slice velocity y (sli:Attack,-10)
show value (1)
)
if (key is pressed(key:d)) then (
set slice velocity x (sli:Attack,10)
show value (2)
)
if (key is pressed(key:a)) then (
set slice velocity x (sli:Attack,-10)
show value (4)
)
end
#----------------------------------------------------------------------------
plotscript, fog,begin #"reveals" all of the blocks
write map block (herox--1, heroy+3, 0, 1) #1 #relative to the hero. Layer
write map block (herox, heroy+3, 0, 1) #2 #1 has to be covered in "shadow"
write map block (herox+1, heroy+3, 0, 1) #3 #which is just black.
write map block (herox--2, heroy+2, 0, 1) #4
write map block (herox--1, heroy+2, 0, 1) #5
write map block (herox, heroy+2, 0, 1) #6
write map block (herox+1, heroy+2, 0, 1) #7
write map block (herox+2, heroy+2, 0, 1) #8
write map block (herox--1, heroy+1, 0, 1) #9
write map block (herox--3, heroy--1, 0, 1) #23
write map block (herox--2, heroy+1, 0, 1) #10
write map block (herox--1, heroy+1, 0, 1) #11
write map block (herox, heroy+1, 0, 1) #12
write map block (herox+1, heroy+1, 0, 1) #13
write map block (herox+2, heroy+1, 0, 1) #14
write map block (herox+3, heroy+1, 0, 1) #15
write map block (herox--3, heroy, 0, 1) # 16
write map block (herox--2, heroy, 0, 1) #17
write map block (herox--1, heroy, 0, 1) #18
write map block (herox, heroy, 0, 1) #19
write map block (herox+1, heroy, 0, 1) #20
write map block (herox+2, heroy, 0, 1) #21
write map block (herox+3, heroy, 0, 1) #22
write map block (herox--3, heroy+1, 0, 1) #23
write map block (herox--2, heroy--1, 0, 1) #24
write map block (herox--1, heroy--1, 0, 1) #25
write map block (herox, heroy--1, 0, 1) #26
write map block (herox+1, heroy--1, 0, 1) #27
write map block (herox+2, heroy--1, 0, 1) #28
write map block (herox+3, heroy--1, 0, 1) #29
write map block (herox--2, heroy--2, 0, 1) #30
write map block (herox--1, heroy--2, 0, 1) #31
write map block (herox, heroy--2, 0, 1) #32
write map block (herox+1, heroy--2, 0, 1) #33
write map block (herox+2, heroy--2, 0, 1) #34
write map block (herox--1, heroy--3, 0, 1) #35
write map block (herox, heroy--3, 0, 1) #36
write map block (herox+1, heroy--3, 0, 1) #37
end
#----------------------------------------------------------------------------
plotscript, runalways, begin
attackcol := load slice collection (1)
attacksl := lookup slice (sli:Attack, attackcol)
playing := true
while(playing == true) do(
fog
atk
wait(1)
)
end
What am I doing wrong? It keeps coming up with the error
"setslicevelocityx: slice handle 4 has already been deleted" and
"slicex: slice handle 4 has already been deleted" and
"slicescreenx: slice handle 4 has already been deleted" and
"setslicevelocityy: slice handle 4 has already been deleted" and
"slicey: slice handle 4 has already been deleted" and
"slicescreeny: slice handle 4 has already been deleted" and
when any of the WASD keys are pressed.
The fog script works just fine though.
I should note that in the "attack" is a sprite in slice collection 1 and it has the lookup code "4 Attack"
The idea was that if a slice is used "slice collide (handle1, handle2)" where handle1 is the attack and handle2 is an enemy onscreen which is just an npc it will destroy that NPC, but again, I'm not too sure about how to do that because I haven't figured out slices.
I could do that, or I suppose, if you guys have any suggestions on how to do that in an easier way, I would surly do that indeed.
What do you guys have to say?
Any comment is appreciated.