Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Enemies Movement In 2d roguelike game

Author
Message
Klim
6
Years of Service
User Offline
Joined: 29th Sep 2018
Location:
Posted: 29th Sep 2018 13:13
Hi guys, i am looking for some help. I always try to code by myself, but now, i think, i need your help.
Problem in movement of enemies, i mean something like artificial intelligence. I dont want u to do all the wotk, just show me the way. Thanks for everyone!

P.S. What can u say about code guys?

cls
x=timer()
randomize x
set display mode 1920,1080,32
set text size 30
sync on
sync rate 60
set image colorkey 255,255,255
load image "Fon1l.png",1
load image "darkcap.png",2
load image "sleep1.png",3
load image "sleep2.png",4
load image "glasfl.png",5
load image "hatfl.png",6
load image "bootsfl.png",7
load image "wake1.png",8
load image "hat.png",9
load image "hatboots.png",10
load image "glas.png",11
load image "glas+bots.png",12
load image "boots.png",13
load image "full.png",14
load image "aim.png",15
load image "press.png",16
load image "diolog.png",17
load image "white.png",18
load image "glashat.png",19
load image "oresh.png",20
load image "blac.png",21
load image "tut.png",22
load image "tutorM.png",23
load image "pickupglas.png",24
load image "pickuphat.png",25
load image "pickupboots.png",26
load image "rev1.png",27
load image "withouthand.png",28
load image "bub1.bmp",29
load image "hadgun2.png",30
load image "hadgun3.png",31
load image "hadgun4.png",32
load image "hadgun5.png",33
load image "реш тень.png",34
load image "shit.png",35
load image "oresh1.png",36
load animation "anime.gif",5
rem ORIGINAL
mishat=253
misboots=253
misglas=253
num=2


MousePosX#=0
MousePosY#=0

DX# = 0
DY# = 0
DZ# = 0
Ang# = 0
Clicked# = 0

b=1000
HandG=30

z=mousex()
c=mousey()
main=3
x=760
y=550
u=1800
i=75
chose=850
fal=80
fal1=1440
draw sprites first
do
set image colorkey 0,0,0
z=mousex()
c=mousey()
go2=z-38
go3=c-36
sprite 1,0,0,1
sprite 2,u,i,2
sprite 3,x,y,Main
sprite 4,z,c,15
offset sprite 4,16,16
if delglas=0
sprite 5,540,540,5
scale sprite 5,350
endif
if delhat=0
sprite 6,800,800,6
scale sprite 6,350
endif
if delbot=0
sprite 7,1200,400,7
scale sprite 7,500
endif
sprite 8,0,0,17
sprite 9,0,0,16
sprite 10,420,chose,18
sprite 11,0,0,20
sprite 12,60,150,22
sprite 13,100,300,23
sprite 19,0,0,34
sprite 20,0,0,35
sprite 21,0,0,36







if delpickglas=0
sprite 14,0,0,24
set sprite priority 14,2
hide sprite 14
endif

if delpickhat=0
sprite 15,0,0,25
set sprite priority 15,2
hide sprite 15
endif

if delpickboots=0
sprite 16,0,0,26
set sprite priority 16,2
hide sprite 16
endif


sprite 18,x+178,y+97,handg
`sprite 18,z,c,handg
rotate sprite 18,90
offset sprite 18,1,26
hide sprite 18
set sprite priority 18,2

hide sprite 12
hide sprite 13
set sprite alpha 10,40
scale sprite 2,400
scale sprite 3,450
scale sprite 4,150
set sprite priority 4,3
set sprite priority 11,1
set sprite priority 13,2
set sprite priority 3,2
hide sprite 8
hide sprite 9
hide sprite 10
hide mouse

scale sprite 18,400



gosub 1stScene
gosub menu
gosub generation
gosub controlHero
gosub shooting


sync
loop



menu:
return

generation:
return



controlHero:
if move2=1
if keystate(17)
y=y-6
endif
if keystate(31)
y=y+6
endif
if keystate(32)
x=x+6
endif
if keystate(30)
x=x-6
endif
endif





rem OGRANICHENYA
if sprite hit(3,21) and keystate(17) then y=y+6
if sprite x(3)<20 then x=x+6
if sprite x(3)>1780 then x=x-6
if sprite y(3)>870 then y=y-6
if sprite y(3)<0 then y=y+6


rem if mouseclick()=1
rem ink rgb (255,255,255),1
rem text 1,50,"Your current x: "+str$(z)
rem text 1,100,"Your current y: "+str$(c)
rem endif








if sprite hit(3,5) and keystate(18)
delete sprite 5
delglas=1
pick1=1
if main=8
main=11
endif
if main=13
main=12
endif
if main=9
main=19
endif
if main=10
main=14
endif
endif
if pick1=1 then show sprite 14
if pick1=1 and spacekey() then pick1=2
if pick1=2
set sprite alpha 14,misglas
misglas=misglas-2
show sprite 14
endif
if misglas<4
delete sprite 14
delpickglas=1
pick1=3
misglas=5
endif













if sprite hit(3,7) and keystate(18)
delete sprite 7
delbot=1


pick2=1
if main=8
main=13
endif
if main=9
main=10
endif
if main=11
main=12
endif
if main=19
main=14
endif
endif




if pick2=1 then show sprite 16
if pick2=1 and spacekey() then pick2=2
if pick2=2
set sprite alpha 16,misboots
misboots=misboots-2
show sprite 16
endif
if misboots<4
delete sprite 16
delpickboots=1
pick2=3
misboots=5
endif






if sprite hit(3,6) and keystate(18)
delete sprite 6
delhat=1

pick3=1



if main=8
main=9
endif

if main=12
main=14
endif


if main=13
main=10
endif


if main=11
main=19
endif


endif





if pick3=1 then show sprite 15
if pick3=1 and spacekey() then pick3=2
if pick3=2
set sprite alpha 15,mishat
mishat=mishat-2
show sprite 15
endif
if mishat<4
delete sprite 15
delpickhat=1
pick3=3
mishat=5
endif


















if sprite hit (3,6)
show sprite 12
endif
if sprite hit (3,7)
show sprite 12
endif
if sprite hit (3,5)
show sprite 12
endif









if sprite hit(3,17)
show sprite 12
endif
if sprite hit(3,17) and keystate(18)
delete sprite 17
main=28
show sprite 18
gun=1
endif







return








1stScene:






if move1=0
u=u-1
endif
if u<1450
move1=1
u=u+3
catscene1=1
endif





if catscene1=1 and switch=500
Main=4
catscene1=0
endif

remstart if switch=600
delete animation 5
contrl=1
endif
remend

if switch>620 and next1<1
set text size 60
set text font "Comic Sans MS"
ink rgb(255,255,255),2
show sprite 8
show sprite 9
text 400,850,"Mysterious figure in a cloak: -Oh, survivor!"
endif

if spacekey()=1 and next1<2
next1=next1+1
sleep 200
endif


if next1=1 and next1<2
text 400,850,"How did you got here?"
show sprite 8
show sprite 9
endif


if next1=2 and next1<3
show sprite 10
text 420,850,"You: - ..."
text 420,950,"You: - I, Didnt remember. I even dont know my name"
show sprite 8
endif


if next1=2 and keystate(31) or downkey()
chose=955
endif
if next1=2 and keystate(17) or upkey()
chose=850
endif


if chose=850 and returnkey() and next1<3
next1=3
endif

if next1=3 and next1<4
show sprite 8
text 400,850,"Ok, at least say me your name"
endif


if chose=955 and returnkey() and next1<3
next1=4
endif

if next1=4 and next1<5
show sprite 8
text 400,850,"Heh, so... choose another"
endif



if spacekey() and next1=3 or next1=4 and spacekey()
next1=5
sleep 200
endif

if next1=5 and next1<6
show sprite 8
set cursor 400,850
input name$
next1=6
endif


if next1=6 and next1<7
show sprite 8
text 400,850,"Ok,"
text 484,850,name$
text 400,950,"Stretch your legs"
move2=1
show sprite 13
endif


if next1=6 and spacekey()
Main=8
next1=7
sleep 200
endif








if main=14 and next2<2 and delpickboots=1 and delpickhat=1 and delpickglas=1
show sprite 8
next2=1
text 400,850,"Now, It seems to me, that You have learnt the basics"
move2=0
endif



if spacekey() and next2>0 and next2<>3
next2=next2+1
sleep 200
endif




if next2=2 and next2<3
show sprite 8
move2=0
text 400,850,"Okey, take this."
endif


if next2=3 and next2<4
fal=fal+3
if switch mod 3=0
fal1=fal1+2
endif
sprite 17,fal1,fal,27
scale sprite 17,40
endif

if fal>480
fal=fal-5
next2=4
move2=1
endif










switch=switch+1
text 100,50,"Your current switch: "+str$(switch)
return








shooting:

`TEXT 100,10, "X: " + STR$(MOUSEX())
`TEXT 100,50, "Y: " + STR$(MOUSEY())
`TEXT 300,10, "Distance: " + STR$(Dist#)
`TEXT 300,50, "Angle: " + STR$(Ang#)




rem Clicked# = 1
if gun=1
show sprite 18
MousePosX# = MOUSEX()
MousePosY# = MOUSEY()

DX# = MousePosX# - SPRITE X(18)
DY# = MousePosY# - SPRITE Y(18)

Dist# = ABS(SQRT(ABS(DX#*DX#) + ABS(DY#*DY#)))

Ang# = WRAPVALUE(atanfull(DX#,-DY#))
shot#=ang#
rem ang#=ang#-92
ROTATE SPRITE 18,Ang#

if ang#>45 and ang#<68
HandG=31
endif


if ang#>100 and ang#<125
HandG=32
endif


if ang#>68 and ang#<100
handg=30
endif


if ang#>125 and ang#<135
handg=33
endif
endif


if gun=1
If Wait#=0
If mouseclick()=1
Sprite B,Sprite X(18),Sprite Y(18),29
set sprite priority b,4
Offset Sprite B,243,131
Rotate Sprite B,shot#
scale sprite b,20
Move sprite B,110
Inc B
Wait#=40
Endif
Endif
dec Wait#
if Wait#<0 then Wait#=0
For FA=1 to 20
If Sprite exist (B-FA) then move sprite B-fa,30
If Sprite exist (B-Fa) Then If Sprite Y(B-fa)<0 then Delete sprite B-fa
If Sprite exist (B-fa) Then If Sprite Y(B-fa)>1080 then Delete sprite B-fa
If Sprite exist (B-fa) Then If Sprite X(B-fa)<0 then Delete sprite B-fa
If Sprite exist (B-fa) Then If Sprite X(B-fa)>1920 then Delete sprite B-fa
Next fa
endif

return














Login to post a reply

Server time is: 2024-11-21 09:03:29
Your offset time is: 2024-11-21 09:03:29