fb:porticula NoPaste
Kleine aber feine KI^^
Uploader: | AndT |
Datum/Zeit: | 12.02.2008 20:40:59 |
' KI 0.8v beta programmiert von AndT
Type xycor
x as integer
y as integer
end type
' -- Setup --
'Screen Setup
width 80,25
locate ,,0
' Startposition
dim shared as xycor f = (23,79) ' Feind
dim shared as xycor m = (7,2) ' Du
# define controler 0 ' Maus oder Keyboard (j,i,k,l) (1/0)
const speed = 10 ' Speed(default = 10)
' Objekte
const objm = CHR(2) ' Feind
const objf = CHR(1) ' Du
dim shared ctrl as string
' -- Setup Ende --
SUB Display
locate 2,1
Print "MX:";m.x,"MY:";m.y
'Du
locate m.x,m.y
Print ObjM
'Feind
locate f.x,f.y
Print ObjF
End Sub
SUB Control
#IF(controler = 0)
ctrl = lcase (INKEY)
Select Case ctrl
case "i"
IF M.X > 25-speed then m.x-=speed
case "k"
IF M.X < 2+speed THEN m.x+=speed
case "j"
IF M.Y > 2+speed THEN m.y-=speed
case "l"
IF M.Y < 80-speed THEN m.y+=speed
case chr(27)
end
end select
#ENDIF
#IF(controler = 1)
getmouse m.y,m.x
m.y+=1
m.x+=1
IF INKEY = CHR(27) THEN END
#ENDIF
#IF (controler < 0 or controler > 1)
Print "Fehler - 'controler' auf 1 oder 0 setzen" : SLEEP : END
#ENDIF
END SUB
Sub KI
'KI-Trigger
if f.x > m.x then f.x -= 1
if f.x < m.x then f.x +=1
if f.y < m.y then f.y +=1
if f.y > m.y then f.y - = 1
IF f.x > 23 then f.x-=1
IF f.x < 1 then f.x+=1
IF f.y > 78 then f.y-=1
IF f.y < 1 then f.y+=1
end sub
SUB GameRule
IF f.x = m.x and f.y = m.y then Print "looser!": beep : sleep:end
End SUB
' MainLoop (Das ist alles)
DO
' Module
Ki
GameRule
Control
Display
sleep 50
cls
LOOP