Hey ive come to a problem that i cant fix.
sync on
`sync rate 1000
backdrop on
color backdrop 0
barhealth# = 0.00000
maxhealth# = 100.00000
health# = maxhealth#
linenumber = 30
gravity# = 0.00981
gravity2# = 9.81
yvelocity# = 0.0000000
xvelocity# = 0.0000000
xdistance# = 0.000
ydistance# = 0.000
bottom# = 150.000
hit = 0
dim dotspeed#(linenumber)
dim hitdotsx#(linenumber)
dim hitdotsy#(linenumber)
dim dotangle#(linenumber)
dim lastx#(linenumber)
dim lasty#(linenumber)
for n = 1 to linenumber
lastx#(n) = 0.0000
lasty#(n) = 0.0000
next n
dim shurix#(5)
dim shuriy#(5)
dim lastshurix#(5)
dim lastshuriy#(5)
for n = 1 to 5
shurix#(n) = x#
shuriy#(n) = y#
next n
dim shurixchange#(5)
dim shuriychange#(5)
dim throw(5)
dim time(5)
dim shuriangle(5)
dim currentangle(5)
spritex# = 320
spritey# = 320
`time(n) = 0
ysize = 16
xsize = 18
flip = 0
dim throwspeed#(5)
aimspeed = 5
x# = 320.0000000
y# = 240.0000000
hide mouse
cls
load bitmap "NinjaSphere.bmp",1
get image 1,34,20,70,52
delete bitmap 1
cls
load bitmap "Brickwall.bmp",2
get image 2,1,1,36,31
delete bitmap 2
load bitmap "Shurikan.bmp",3
get image 3,2,2,34,30
delete bitmap 3
`sprite 1,shurix#(1),shuriy#(1),3
for n = 1 to 5
`clone sprite 1, n
sprite n,shurix#(n),shuriy#(n),3
scale sprite n, 75
offset sprite n,0,15
next n
sprite 6,x#,y#,1
offset sprite 6, 18, 16
scale sprite 6, 75
sprite 7,spritex#,spritey#,2
offset sprite 7,17,15
`scale sprite 1, 75
do
`cls
`reseting variables
maxhealth# = 100
for n = 1 to 5
lastshurix#(n) = shurix#(n) + shurixchange#(n)
lastshuriy#(n) = shuriy#(n) + shuriychange#(n)
next n
set sprite diffuse 6,255,255,255
`sync
xdistance = x#-mousex()
ydistance = y#-mousey()
deltax# = 0.00000
deltay# = 0.00000
for n = 1 to 5
shurixchange#(n) = 0.00000
shuriychange#(n) = 0.00000
if throw(n) = 0
shurix#(n) = x#
shuriy#(n) = y#
throwspeed#(n) = 5.000
endif
next n
`gravity equations
yvelocity# = yvelocity# + gravity#
if bottom# <= 0 `- ysize
y# = y# - 0.1
bottom# = bottom# +0.1
` spritey# = 0 `- ysize
collision = 1
` if abs(yvelocity#) < 0.02
` yvelocity# = 0.00000000
` endif
xvelocity# = xvelocity# * 0.6
yvelocity# = yvelocity# * -0.6
endif
`input commands
if health > 0
if upkey() = 1
`yvelocity# = yvelocity# - 0.0025
if collision = 1
yvelocity# = yvelocity# - 0.7000
endif
endif
if leftkey() = 1
xvelocity# = xvelocity# - 0.0055
if collision = 1
xvelocity# = xvelocity# - 0.7000
yvelocity# = yvelocity# -0.2
endif
endif
if rightkey() = 1
xvelocity# = xvelocity# + 0.0055
if collision = 1
xvelocity# = xvelocity# + 0.7000
yvelocity# = yvelocity# -0.2
endif
endif
endif
`aiming
shotangle = (-1 * atanfull(xdistance,ydistance)) - 90
`t = 1
if hit <> 1
ink rgb(0,0,255),0
for t = 1 to 135
deltax# = aimspeed*(cos(shotangle))*t
deltay# = (sin(shotangle)*aimspeed)*t + ((gravity2#*(t^2))/2)/1000
dot x# + deltax# , y# + deltay#
`print deltay#
next t
endif
ink rgb(255,255,255),0
if mouseclick() = 1 and stall + 300 < timer()
for n = 5 to 1 step -1
if throw(n) = 0
selector = n
endif
next n
throw(selector) = 1
stall = timer()
endif
for n = 1 to 5
if throw(n) = 1
if time(n) = 0
currentangle(n) = shotangle
shurix#(n) = x#
shuriy#(n) = y#
endif
time(n) = time(n) + 1
shurixchange#(n) = (throwspeed#(n)*(cos(currentangle(n)))*time(n))`/1000
shuriychange#(n) = (sin(currentangle(n))*throwspeed#(n))*time(n) + ((gravity2#*(time(n)^2))/2)/1000
shuriangle(n) = shuriangle(n) + 3
offset sprite n, 16,14
rotate sprite n, shuriangle(n)
endif
next n
for n = 1 to 5
if shuriy#(n) + shuriychange#(n) > 480 `or shurix#(n) + shurixchange#(n) > 640 or shurix#(n) + shurixchange#(n) < 0
throw(n) = 0
time(n) = 0
shuriangle(n) = 0
offset sprite n,0,15
endif
next n
`wrap around
if spritex# < -800 or spritex# > 800
spritex# = spritex# * -1
endif
for n = 1 to 5
if shurix#(n)+ shurixchange#(n) > 800
shurixchange#(n) = shurixchange#(n) - 1600
endif
if shurix#(n)+ shurixchange#(n) < -800
shurixchange#(n) = shurixchange#(n) + 1600
endif
next n
`draw sprite
xdistance# = (((x# - 320)/90)^2) * ((x# - 320)/abs(x#-320))
ydistance# = (((y# - 240)/90)^2)
if y# < 240
ydistance# = ydistance# * -1
endif
x# = x# + xvelocity# - xdistance#
y# = y# + yvelocity# - ydistance#
spritex# = spritex# - xdistance#` - xvelocity#
spritey# = spritey# - ydistance#` - yvelocity#
bottom# = bottom# - yvelocity#
for n = 1 to 5
if throw(n) = 1
shurix#(n) = shurix#(n) - xvelocity#
shuriy#(n) = shuriy#(n) - yvelocity#
endif
next n
angle = -1 * atanfull(xdistance,ydistance)
`if health > 0
rotate sprite 6, angle - 90
`endif
for n = 1 to 5
if throw(n) <> 1
rotate sprite n, angle - 90
endif
next n
sprite 6,x#,y#,1
for n = 1 to 5
sprite n,shurix#(n) + shurixchange#(n),shuriy#(n)+ shuriychange#(n),3
next n
`if health > 0
if mousex() < x# and flip = 0
flip sprite 6
flip = 1
endif
if mousex() > x# and flip = 1
flip sprite 6
flip = 0
endif
`endif
sprite 7,spritex#,spritey#,2
`hit?
if sprite hit(6,7)
if x# < 320 or x# > 320
xvelocity# = xvelocity# * -1
endif
if y# < 340 or y# > 340
yvelocity# = yvelocity# *-0.5
endif
endif
collision = 0
`hit
remstart
if inkey$() = "d" and hit = 0
hit = 1
for n = 1 to linenumber
hitdotsx#(n) = 0.000
hitdotsy#(n) = 0.000
hitdotsx#(n) = x#
hitdotsy#(n) = y#
dotspeed#(n) = rnd (5) + 1 `speedmod * 0.03
dotangle#(n) = atanfull((shurix#
next n
hittimer = timer()
endif
remend
`[immunity]
if immunetimer + 1000 > timer()
hit = 0
set sprite diffuse 6,0,0,255
show sprite 6
for n = 1 to 5
show sprite n
next n
endif
if hit = 0
hittimer = timer()
endif
`[/immunity]
if hit = 1 and hittimer + 100 > timer()
ink rgb(0,0,255),0
`hide sprite 6
for z = 1 to 5
if throw(z) <> 1
throw(z) = 1
randomspeed = rnd(150)
throwspeed#(z) = randomspeed * 0.01
endif
next z
whichhit = sprite collision(6,0)
for n = 1 to linenumber
lastx#(n) = x# + (rnd(10) - 5)
lasty#(n) = y# + (rnd(10) - 5)
next n
for t = 1 to 45
for n = 1 to linenumber
hitdotsx#(n) = (dotspeed#(n)*(cos(dotangle#(n)))*t)
hitdotsy#(n) = ((sin(dotangle#(n))*dotspeed#(n))*t + ((gravity2#*(t^2))/2)/1000)
line lastx#(n),lasty#(n),x# + hitdotsx#(n), y# + hitdotsy#(n)
lastx#(n) = x# + hitdotsx#(n)
lasty#(n) = y# + hitdotsy#(n)
next n
next t
health# = health# - 1
`xvelocity# = 0
`yvelocity# = 0
remstart
for n = 1 to 90
dottime# = (timer() - hittimer)/1000
hitdotsx#(n) = ((dotspeed#(n)/5)*(cos(dotangle#(n)))*dottime#)
hitdotsy#(n) = ((sin(dotangle#(n))*(dotspeed#(n)/5))*dottime# + ((gravity2#*(dottime^2))/2)/1000)
circle x# + hitdotsx#(n), y# + hitdotsy#(n), 1
`sync
next n
remend
endif
for n = 1 to 5
if sprite collision(6,n) and throw(n) = 1 and time(n) > 100 `and immunetimer + 2000 < timer()
hit = 1
for n = 1 to linenumber
hitdotsx#(n) = 0.000
hitdotsy#(n) = 0.000
hitdotsx#(n) = x#
hitdotsy#(n) = y#
dotspeed#(n) = rnd (5) + 1 `speedmod * 0.03
whichhit = sprite collision(6,0)
dotangle#(n) = atanfull((shurix#(whichhit)+shurixchange#(whichhit)) - lastshurix#(whichhit),(shuriy#(whichhit)+shuriychange#(whichhit)) - lastshuriy#(whichhit)) * -1
dotangle#(n) = dotangle#(n) + (rnd(90) - 45) - 90
next n
hittimer = timer()
endif
next n
if hittimer + 100 < timer()
hit = 2
show sprite 6
for n = 1 to 5
show sprite n
next n
immunetimer = timer()
endif
remstart
if immunetimer + 2000 < timer()
hit = 0
show sprite 6
for n = 1 to 5
show sprite n
next n
endif
remend
if sprite visible(6) = 0
for n = 1 to 5
if throw(n) = 0
hide sprite n
endif
next n
endif
`hp bar
barhealth# = (health# / maxhealth#) * 640
ink rgb(255,0,0),0
box 0,2,barhealth#,6
if health# <= 0
health# = 0
rotate sprite 6, 45
if deathtimer = 0
deathtimer = timer()
endif
endif
if deathtimer + 2000 < timer() and health = 0
health = 100
for n = 1 to 5
throw(n) = 0
next n
spritex# = 320
spritey# = 320
immunetimer = timer()
deathtimer = 0
bottom# = 150
endif
sync
loop
wait key
I tried to make it so when u die, you cant move and rotate the character. DarkBasic seems to igore those commands and does it anyway. Also it wont reset the position when u die. Help is appreciated
Also ive posted the exe with the media -->
edit: oh and you kill yourself with your shurikens
32,95,179,95,218
60,58,95,61,95,61,41
192,32,179,32,217