07-21-2023, 06:38 AM
RoboFloorPainter by roq/mnr
Code: (Select All)
'by "roquedrivel" 16/07/23
'robot floor painter
var xi, yi, px, py, xm, ym, ox, oy, i, p, q, f
var mza, dtime, kount, myd1, myd2
var mz[3000]
'initialize
px = Rand(200)
py = Rand(150)
i = 1
label lb01
mz[i] = 0
i = i + 1
if i < 3001 : goto lb01 : endif
wcolor 0, 0, 0
q = 0
choosedirection()
kount = 0
label mloop
'display the robot
mza = 200 * py - 200
mza = mza + px - 1
mz[mza] = 1
ox = (px - 1) * 3
oy = (py - 1) * 3
fcolor 255, 160, 64
dasprite()
swap
fcolor 255, 255, 255
rect 0,0,100,26 : print 4, 4, px : print 60, 4, py
'swap
dtime = 10
mydelay()
'fcolor 0, 0, 0
'print 0, 0, px
'print 40, 0, py
'swap
fcolor 96, 96, 96
dasprite()
pset ox + 1, oy
pset ox + 2, oy + 1
pset ox, oy + 1
pset ox + 1, oy + 2
'attempt to move the robot
xm = 1
ym = 1
f = 0
ox = px
oy = py
px = px + xi
py = py + yi
if px < 1
f = 1
endif
if px > 200
f = 1
endif
if py < 1
f = 1
endif
if py > 150
f = 1
endif
if f = 1
choosedirection()
getoffedge()
endif
mza = 200 * (py - 200)
mza = mza + px - 1
if mz[mza] = 1
px = ox
py = oy
label lb11
choosedirection()
tryagain()
if f = 0 : goto cloop : endif
px = ox
py = oy
kount = kount + 1
if kount < 10000 : goto lb11 : endif
goto cloop
endif
label cloop
'swap
if kount < 10000 : goto mloop : endif
fcolor 192, 192, 192
print 0, 40, "I have gone on strike!"
swap
func mydelay()
myd1 = 0
while myd1 < 100
myd1 = myd1 + 1
myd2 = 0
while myd2 < dtime
myd2 = myd2 + 1
wend
wend
endfn
func choosedirection()
label choosedirection01
xi = Rand(2) - 1
yi = Rand(2) - 1
if xi = 0 : if yi = 0 : goto choosedirection01 : endif : endif
endfn
func dasprite()
pset ox, oy
pset ox + 1, oy + 1
pset ox + 2, oy + 2
pset ox, oy + 2
pset ox + 2, oy
'swap
endfn
func tryagain()
p = Rand(1) + 1
if p = 1 : xm = xm + 1 : endif
if p = 2 : ym = ym + 1 : endif
px = px + xi * xm
py = py + yi * ym
mza = 200 * (py - 200)
mza = mza + px - 1
f = mz[mza]
endfn
func getoffedge()
if px < 1
px = 1
xi = 1
xm = xm + 1
px = px + xi * xm
endif
if px > 200
px = 200
xi = (-1)
xm = xm + 1
px = px + xi * xm
endif
if py < 1
py = 1
yi = 1
ym = ym + 1
py = py + yi * ym
endif
if py > 150
py = 150
yi = 1 ' -1
ym = ym + 1
py = py + yi * ym
endif
endfn
micro(A)developer
http://basic4us.epizy.com/forum/index.php
http://basic4us.epizy.com/forum/index.php