Post by OddChild on Jun 18, 2006 5:32:50 GMT -5
' collision test -- rectangular (bounding box)
option explicit
dim bRunning
bRunning = True
dim mymusic
dim cheese
dim newguy2gotit ' cheeseangle = 0
dim tractboy, image2, background
dim ret, downwalking, guy2, tracted, clonegotit, leftwalking, upwalking
dim newguy1, newguy2, newguy1gotit, car, light, friend
newguy1gotit= 0
clonegotit=0
tracted = 4
dim Font1
dim x, y
x = 100: y = 300
upwalking = 1
leftwalking = 4
dim rater
rater = 2
sub main()
if (graphics.initialize <> True) then exit sub
graphics.setTitle "TractBoy III"
randomize
key.initialize
music.initialize
mymusic = music.loadmidi("hopnbop.mid")
music.playmidi mymusic
music.SetLoopPlay mymusic, true
Font1 = graphics.createFont ("System", 14)
background = graphics.loadimage("Back4.bmp", &HFFFF0000)
tractboy = graphics.loadimage("bartt.png")
image2 = graphics.loadimage("man.png")
friend = graphics.loadimage ("bartender.png")
guy2 = graphics.cloneImage(image2)
car = graphics.loadimage ("copcar2.bmp")
newguy1 = graphics.loadimage("newguy1.png")
graphics.setanimated newguy1, true
newguy2 = graphics.loadimage("newguy2.png")
' graphics.setanimated newguy1, true
graphics.setanimated newguy2, true
graphics.setanimated guy2, true
light = graphics.loadimage ("light.bmp")
graphics.setxY guy2, 0, 200
graphics.setxy light, 400, 200
graphics.setscalex background, 1.2
graphics.SetAnimated tractboy, true
'graphics.setscaleY image1, 4
graphics.setscaley friend, 0.6
graphics.setscalex friend, 0.6
graphics.setanimated friend, true
graphics.settotalframes friend, 48
graphics.setcurrentFrame friend, 1
graphics.settotalframes tractboy, 12
graphics.settotalFrames newguy1, 12
graphics.settotalFrames newguy2, 12
graphics.setcurrentFrame newguy1, 1
graphics.setcurrentFrame newguy2, 4
graphics.setanimated image2, true
graphics.setcurrentFrame tractboy, 1
graphics.settotalframes image2, 12
graphics.setcurrentframe image2, 3
downwalking = 3
tracted = 4
graphics.setautogoto friend, 800, -300, 30000
graphics.setxy car,4020,430
graphics.setautogoto car, -200, 430, 35000
With graphics
.setX tractboy, x
.setY tractboy, y
.setX image2, 200
.setY image2, 100
.setscalex image2, 1
.setscaley image2, 1
.setscalex tractboy, 1
.setscaley tractboy, 1
.setscalex background, 1.4
.setscaley background, 1.2
' .SetAnimated tractboy, True ' tell the application to treat this as an animated image
.SetFrameWidth tractboy, 25 ' the width of a single frame
.SetFrameHeight tractboy, 33
.setframewidth friend, 50
.setframeheight friend, 70' the height of a single frame
.setxy friend, -300,500
'.SetAnimateTime tractboy, 10
.setframewidth image2, 25
.setframeheight image2, 33
.setframewidth guy2, 25
.setframeheight guy2, 33
.setframewidth newguy2, 25
.setframeheight newguy2, 33
.setframewidth newguy1, 25
.setframeheight newguy1, 33
.setxy newguy1, Int((200 - 20 + 1) * Rnd + 200), 300
.setxy newguy2, 300, 400
' .SetAutogoto guy2, 500, 500, 20000
.setcurrentframe guy2, 3
.setautogoto newguy1, -200, -30, 30000
.setautogoto newguy2, -30, Int((617 - 20 + 1) * Rnd + 40), 30000
.SetAutogoto image2, Int((617 - 20 + 1) * Rnd + 20), 500, 30000
.setautogoto guy2, Int((617 - 20 + 1) * Rnd + 20), 500, 30000
End With
dim hegotit
hegotit= 0
do while bRunning = True
graphics.setcurrentFrame tractboy, rater
' rater = rater + 0.001
downwalking = downwalking + 0.005
upwalking = upwalking + 0.005
graphics.setcurrentframe friend, upwalking
if upwalking > 1.9 then upwalking = 1 : if upwalking < 1 then upwalking = 1
leftwalking = leftwalking + 0.005
if leftwalking >4.9 then leftwalking = 4 : if leftwalking < 4 then leftwalking = 4
if newguy1gotit = 0 then graphics.setcurrentframe newguy1, upwalking
graphics.setcurrentframe newguy2, leftwalking
if clonegotit = 0 then graphics.setcurrentframe guy2, downwalking
if downwalking >= 4 then downwalking = 3
if hegotit = 0 then graphics.setcurrentframe image2, downwalking
if newguy2gotit = 0 then graphics.setcurrentframe newguy2, leftwalking
if key.pressed(1) or key.pressed(0) = True then bRunning = False
if key.pressed(200) = True then
y = y - .15 : graphics.sety tractboy, y ' move Up
rater = rater + 0.01
if y < 100 then y = 100
if rater < 1 then rater = 1
if rater >= 2 then rater = 1
end if
' end if
if key.pressed(208) = True then
y = y + .15 ' Down
rater = rater + 0.01
if rater < 3 then rater = 3
if rater >= 4 then rater = 3
if y > 449 then y = 449
graphics.sety tractboy, y
end if
' end if
' end if
if key.pressed(203) = True then
x = x - .15 : graphics.setx tractboy, x ' Left
rater = rater + 0.01
if rater < 4 then rater = 4
if rater > 4.9 then rater = 4
if x< 0 then x = 0
end if
if key.pressed(205) = True then
x = x + .15 : graphics.setx tractboy, x ' Right
rater = rater + 0.01
if x > 617 then x = 617
if rater < 2 then rater = 2
if rater >= 3 then rater = 2
end if
graphics.clear 255
'graphics.settext "press up, down, left, right, arrow keys", 10,10,Font1
graphics.setimage background
graphics.setimage friend
graphics.setimage image2
graphics.setimage guy2
graphics.setimage car
graphics.setimage tractboy
graphics.setimage newguy1
graphics.setimage newguy2
graphics.setimage light
tracted = tracted + 0.005
if tracted < 4 then tracted = 4
if tracted > 4.9 then tracted = 4
if hegotit = 1 then graphics.setcurrentframe image2, tracted
if clonegotit = 1 then graphics.setcurrentframe guy2, tracted
if newguy2gotit = 1 then
graphics.setcurrentframe newguy2, tracted
end if
if newguy1gotit = 1 then
graphics.setcurrentframe newguy1, tracted
end if
ret = graphics.GetCollision(tractboy, image2)
If ret = true then
graphics.settext "Thank you for this tract.", 10,30,Font1
hegotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
'ret = graphics.GetCollision(tractboy, newguy2)
ret = graphics.GetCollisionCustom(0, 0, 1, 1, 2, 2, 3, 3)
If ret = true then
graphics.settext "Leave me Alone", 10,30,Font1
newguy2gotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
ret = graphics.GetCollision(tractboy, newguy1)
If ret = true then
graphics.settext "Thank You.", 10,30,Font1
newguy1gotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
ret = graphics.GetCollision(tractboy, guy2)
If ret = true then
graphics.settext "Thank you for this tract.", 10,30,Font1
clonegotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
ret = graphics.GetCollision(tractboy, car)
If ret = true then
graphics.settext "You Got Ran Over", 10,30,Font1
'clonegotit = 1
x = x + 10
'graphics.SetAutogoto image2, 400, 500, 15000
end if
'if hegotit = 1 then graphics.setcurrentframe image2, tracted
' end if
graphics.display
loop
key.terminate
graphics.terminate
music.terminate
end sub
Call main
option explicit
dim bRunning
bRunning = True
dim mymusic
dim cheese
dim newguy2gotit ' cheeseangle = 0
dim tractboy, image2, background
dim ret, downwalking, guy2, tracted, clonegotit, leftwalking, upwalking
dim newguy1, newguy2, newguy1gotit, car, light, friend
newguy1gotit= 0
clonegotit=0
tracted = 4
dim Font1
dim x, y
x = 100: y = 300
upwalking = 1
leftwalking = 4
dim rater
rater = 2
sub main()
if (graphics.initialize <> True) then exit sub
graphics.setTitle "TractBoy III"
randomize
key.initialize
music.initialize
mymusic = music.loadmidi("hopnbop.mid")
music.playmidi mymusic
music.SetLoopPlay mymusic, true
Font1 = graphics.createFont ("System", 14)
background = graphics.loadimage("Back4.bmp", &HFFFF0000)
tractboy = graphics.loadimage("bartt.png")
image2 = graphics.loadimage("man.png")
friend = graphics.loadimage ("bartender.png")
guy2 = graphics.cloneImage(image2)
car = graphics.loadimage ("copcar2.bmp")
newguy1 = graphics.loadimage("newguy1.png")
graphics.setanimated newguy1, true
newguy2 = graphics.loadimage("newguy2.png")
' graphics.setanimated newguy1, true
graphics.setanimated newguy2, true
graphics.setanimated guy2, true
light = graphics.loadimage ("light.bmp")
graphics.setxY guy2, 0, 200
graphics.setxy light, 400, 200
graphics.setscalex background, 1.2
graphics.SetAnimated tractboy, true
'graphics.setscaleY image1, 4
graphics.setscaley friend, 0.6
graphics.setscalex friend, 0.6
graphics.setanimated friend, true
graphics.settotalframes friend, 48
graphics.setcurrentFrame friend, 1
graphics.settotalframes tractboy, 12
graphics.settotalFrames newguy1, 12
graphics.settotalFrames newguy2, 12
graphics.setcurrentFrame newguy1, 1
graphics.setcurrentFrame newguy2, 4
graphics.setanimated image2, true
graphics.setcurrentFrame tractboy, 1
graphics.settotalframes image2, 12
graphics.setcurrentframe image2, 3
downwalking = 3
tracted = 4
graphics.setautogoto friend, 800, -300, 30000
graphics.setxy car,4020,430
graphics.setautogoto car, -200, 430, 35000
With graphics
.setX tractboy, x
.setY tractboy, y
.setX image2, 200
.setY image2, 100
.setscalex image2, 1
.setscaley image2, 1
.setscalex tractboy, 1
.setscaley tractboy, 1
.setscalex background, 1.4
.setscaley background, 1.2
' .SetAnimated tractboy, True ' tell the application to treat this as an animated image
.SetFrameWidth tractboy, 25 ' the width of a single frame
.SetFrameHeight tractboy, 33
.setframewidth friend, 50
.setframeheight friend, 70' the height of a single frame
.setxy friend, -300,500
'.SetAnimateTime tractboy, 10
.setframewidth image2, 25
.setframeheight image2, 33
.setframewidth guy2, 25
.setframeheight guy2, 33
.setframewidth newguy2, 25
.setframeheight newguy2, 33
.setframewidth newguy1, 25
.setframeheight newguy1, 33
.setxy newguy1, Int((200 - 20 + 1) * Rnd + 200), 300
.setxy newguy2, 300, 400
' .SetAutogoto guy2, 500, 500, 20000
.setcurrentframe guy2, 3
.setautogoto newguy1, -200, -30, 30000
.setautogoto newguy2, -30, Int((617 - 20 + 1) * Rnd + 40), 30000
.SetAutogoto image2, Int((617 - 20 + 1) * Rnd + 20), 500, 30000
.setautogoto guy2, Int((617 - 20 + 1) * Rnd + 20), 500, 30000
End With
dim hegotit
hegotit= 0
do while bRunning = True
graphics.setcurrentFrame tractboy, rater
' rater = rater + 0.001
downwalking = downwalking + 0.005
upwalking = upwalking + 0.005
graphics.setcurrentframe friend, upwalking
if upwalking > 1.9 then upwalking = 1 : if upwalking < 1 then upwalking = 1
leftwalking = leftwalking + 0.005
if leftwalking >4.9 then leftwalking = 4 : if leftwalking < 4 then leftwalking = 4
if newguy1gotit = 0 then graphics.setcurrentframe newguy1, upwalking
graphics.setcurrentframe newguy2, leftwalking
if clonegotit = 0 then graphics.setcurrentframe guy2, downwalking
if downwalking >= 4 then downwalking = 3
if hegotit = 0 then graphics.setcurrentframe image2, downwalking
if newguy2gotit = 0 then graphics.setcurrentframe newguy2, leftwalking
if key.pressed(1) or key.pressed(0) = True then bRunning = False
if key.pressed(200) = True then
y = y - .15 : graphics.sety tractboy, y ' move Up
rater = rater + 0.01
if y < 100 then y = 100
if rater < 1 then rater = 1
if rater >= 2 then rater = 1
end if
' end if
if key.pressed(208) = True then
y = y + .15 ' Down
rater = rater + 0.01
if rater < 3 then rater = 3
if rater >= 4 then rater = 3
if y > 449 then y = 449
graphics.sety tractboy, y
end if
' end if
' end if
if key.pressed(203) = True then
x = x - .15 : graphics.setx tractboy, x ' Left
rater = rater + 0.01
if rater < 4 then rater = 4
if rater > 4.9 then rater = 4
if x< 0 then x = 0
end if
if key.pressed(205) = True then
x = x + .15 : graphics.setx tractboy, x ' Right
rater = rater + 0.01
if x > 617 then x = 617
if rater < 2 then rater = 2
if rater >= 3 then rater = 2
end if
graphics.clear 255
'graphics.settext "press up, down, left, right, arrow keys", 10,10,Font1
graphics.setimage background
graphics.setimage friend
graphics.setimage image2
graphics.setimage guy2
graphics.setimage car
graphics.setimage tractboy
graphics.setimage newguy1
graphics.setimage newguy2
graphics.setimage light
tracted = tracted + 0.005
if tracted < 4 then tracted = 4
if tracted > 4.9 then tracted = 4
if hegotit = 1 then graphics.setcurrentframe image2, tracted
if clonegotit = 1 then graphics.setcurrentframe guy2, tracted
if newguy2gotit = 1 then
graphics.setcurrentframe newguy2, tracted
end if
if newguy1gotit = 1 then
graphics.setcurrentframe newguy1, tracted
end if
ret = graphics.GetCollision(tractboy, image2)
If ret = true then
graphics.settext "Thank you for this tract.", 10,30,Font1
hegotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
'ret = graphics.GetCollision(tractboy, newguy2)
ret = graphics.GetCollisionCustom(0, 0, 1, 1, 2, 2, 3, 3)
If ret = true then
graphics.settext "Leave me Alone", 10,30,Font1
newguy2gotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
ret = graphics.GetCollision(tractboy, newguy1)
If ret = true then
graphics.settext "Thank You.", 10,30,Font1
newguy1gotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
ret = graphics.GetCollision(tractboy, guy2)
If ret = true then
graphics.settext "Thank you for this tract.", 10,30,Font1
clonegotit = 1
'graphics.SetAutogoto image2, 400, 500, 15000
end if
ret = graphics.GetCollision(tractboy, car)
If ret = true then
graphics.settext "You Got Ran Over", 10,30,Font1
'clonegotit = 1
x = x + 10
'graphics.SetAutogoto image2, 400, 500, 15000
end if
'if hegotit = 1 then graphics.setcurrentframe image2, tracted
' end if
graphics.display
loop
key.terminate
graphics.terminate
music.terminate
end sub
Call main
There is some code. I think that classes would make the code MUCH shorter, rather than having it so repetitive.
rapidsharing.com/download.php?id=123C7040
The above link is to the demo. After it installs, to play the level that the code is above, you must open level 2 manually as i have not yet connected lvl1 and lvl 2. You can find level 2 at C:\program files\tractboy\lvl2.exe
That should do it.