Hi all.I have been ajusting an old game I made time ago...trying to make all media with code, and trying to get sounds working...but for a game without media, it is hard to do some kind of thins.I would like to add much more...and perhaps in a new version. I hope you enjoy it !
rem Sounds `based on Ric's original code and modified to use memblocks by Green Gandalf
set display mode 1024,768,32
set ambient light 50
make light 1:position light 1,3280,250,2730
set light range 1,200
rem please wait message
autocam off :hide mouse
set cursor 450,350:print "PLEASE WAIT...."
sync
sync on
rem TEXTURES ==========================================================
rem ===================================================================
`CLOUDS TEXTURE
for p= 1 to 1
for i= 1 to 100
bo=-10+rnd(100)
ba=-10+rnd(100)
tm=2+rnd(15)
color=rnd(155)
ink rgb(color,color,color+100),1
box bo,ba,bo+tm,ba+tm
next i
for x= 1 to 100
for z= 1 to 100
dz=rnd(5)
col=point(x,z)/1000
if col>15000 then ink rgb(200,200,255),1:dot dz+100+x,z+dz
if col<15000 then ink rgb(150,150,200),1:dot dz+100+x,z+dz
if col<12000 then ink rgb(140,140,170),1:dot dz+100+x,z+dz
if col<9000 then ink rgb(130,130,150),1:dot dz+100+x,z+dz
if col<7000 then ink rgb(100,100,150),1:dot dz+100+x,z+dz
if col<5000 then ink rgb(50,50,150),1:dot dz+100+x,z+dz
next z
next x
get image 500,100,0,200,100,0
next p
create bitmap 1,100,100
paste image 500,0,0
blur bitmap 1,6
get image 500,0,0,100,100,0
delete bitmap 1
rem wood texture ------------------------------------------------------
create bitmap 1,100,100
ink rgb(90,70,40),1
box 0,0,100,100:
ink rgb(60,50,20),1
for a= 1 to 2
for i= 1 to 100 step 5
line 0,i-13+rnd(16),100,i-13+rnd(16)
ink rgb(30+rnd(30),40,20),1
next i
next a
ink rgb(5,5,5),1
box 0,24,100,26
box 0,49,100,51
box 0,74,100,76
blur bitmap 1,4
get image 1,0,0,100,100
rem cantina`s roof ---------------------------------------------
for i= 1 to 20
ink rgb(0,0,0),1
line 0,20-i,50,0
line 100,20-i,50,0
ellipse 50,20,i/1.5,i/1.5
next i
get image 2,0,0,100,50,1
delete bitmap 1
paste image 1,0,0
rem desert texture ------------------------------------------------
ink rgb(90,80,50),1
box 0,0,20,20
for i= 1 to 200
dot rnd(20),rnd(20),rgb(90+rnd(20),80+rnd(10),50+rnd(10))
next i
get image 3,0,0,20,20
rem pine texture -------------------------------------------------
cls
for i= 1 to 500
ink rgb(0,rnd(155),0),1
a=rnd(100)
b=rnd(100)
box a,b,a+4,b+4
next i
get image 4,0,0,100,100,1
rem trunck texture --------------------------------------------------
cls
ink rgb(90,60,50),1
box 0,0,20,20
for i= 1 to 200
dot rnd(20),rnd(20),rgb(20+rnd(20),10,10)
next i
get image 5,0,0,20,20
rem white wood texture ---------------------------------------------
for i= 1 to 50
dg=255-i*3
ink rgb(dg,dg,dg),1
line 0,i,100,i
next i
get image 6,1,1,99,49
rem red
cls
ink rgb(100,0,0),1
box 0,0,10,10
get image 7,1,1,9,9
rem fense
cls
ink rgb(200,200,200),1
for i= 1 to 50
circle 0,10+i,5
circle 100,10+i,5
next i
box 0,15,100,25
box 0,45,100,55
get image 8,0,5,100,60
rem flyes
cls
ink rgb(0,0,0)
box 0,0,5,5
get image 9,0,0,5,5
rem horse texture
cls
ink rgb(90,80,40),1
box 0,0,100,100
for i= 1 to 1000
col=90+rnd(20)
ink rgb(col,col-20,40),1
a=rnd(100)
b=rnd(100)
line a,b,a+rnd(5),b+10
next i
get image 10,0,0,100,100
rem cactus
rem creating the image
cls
for i= 1 to 100
ink rgb(0,100+rnd(5),0),1
if i<40 then inc v
if i>40 then inc h:inc v
if i>70 then inc v
if i>80 then dec h
if i>80 then inc g
ellipse 100+h,300-v,10,10
ellipse 100-h,255-v,10,10
ellipse 100,220-v,10,10
ellipse 100+h,300-v,9,9
ellipse 100-h,255-v,9,9
ellipse 100,220-v,9,9
ellipse 100+h/2,180-v/2,6,8
next i
rem geting image
get image 11,0,0,210,310,1
rem pasting image
paste image 11,0,0
rem noise to the image
for i= 0 to 210
for a= 0 to 310
col=point(i,a)
if col>0 then dot i,a,rgb(70,100+rnd(100),70)
next a
next i
get image 11,50,80,210,310,1
rem bottles
cls
ink rgb(0,80,0),1
for i= 1 to 20
ellipse 10,30-i,5,3
ellipse 10,20-i,2,1
next i
ink rgb(10,90,10),1
for i= 1 to 20
ellipse 23,30-i,5,3
ellipse 23,20-i,2,1
next i
ink rgb(100,80,0),1
for i= 1 to 20
ellipse 36,30-i,5,3
ellipse 36,20-i,2,1
next i
ink rgb(90,60,10),1
for i= 1 to 20
ellipse 49,30-i,5,3
ellipse 49,20-i,2,1
next i
ink rgb(10,90,10),1
for i= 1 to 20
ellipse 62,30-i,5,3
ellipse 62,20-i,2,1
next i
ink rgb(90,70,20),1
box 0,30,70,34
get image 12,4,0,70,34
get image 13,0,0,16,31,1
rem mask
ink rgb(200,200,200),1
box 4,0,70,30
ink rgb(0,0,0),1
box 0,0,16,30
get image 14,4,0,70,34
rem brown colour
cls
ink rgb(90,70,25),1
box 0,0,30,30
get image 15,0,0,30,30
rem SALOON texture
ink rgb(255,255,255),1
box 0,0,100,15
ink rgb(150,0,0),1
set cursor 0,0
print "S A L O O N"
ink rgb(0,0,0),1
for i= 1 to 40
dot rnd(90),rnd(15)
next
get image 16,0,0,90,15,1
rem dark brown
cls
ink rgb(70,50,10),1
box 0,0,30,30
get image 17,0,0,30,30,1
rem boxes texture
create bitmap 1,50,50
ink rgb(250,250,250),1
box 2,2,48,48
ink rgb(0,0,0),1
line 0,0,50,50
line 0,1,49,50
line 1,0,50,49
line 0,50,50,0
line 0,49,49,0
line 1,50,50,1
blur bitmap 1,2
get image 18,0,0,50,50,1
delete bitmap 1
rem white door
cls
ink rgb(190,190,190),1
for i= 1 to 40
ellipse 25,18+i,20,13
next i
ink rgb(155,155,190),1
for i= 1 to 40
ellipse 25,18+i,16,10
next
ink rgb(190,190,190),1
box 23,10,27,100
box 8,20,46,24
box 8,35,46,39
box 8,50,46,54
get image 19,0,0,46,54,1
rem gray
ink rgb(90,90,90),1
box 0,0,5,5
get image 20,0,0,5,5,1
rem saloon window
ink rgb(70,50,10),1
box 0,0,50,50
ink rgb(0,0,0),1
box 5,5,45,45
get image 21,0,0,50,50
rem fire
ink rgb(0,0,0),1
box 0,0,100,100
ink rgb(255,255,255),1
for i= 1 to 20
line 10,10,50+i,50
line 50,20,50+i,50
line 90,9,50+i,50
line 90,50,50,45+i
line 50,90,50+i,40
next
get image 22,0,0,100,100,1
rem gun texture
cls
for i= 1 to 10
col=i*3
ink rgb(50+col,50+col,50+col),1
line 10,10+i,100,10+i
line 10,5+i,100,5+i
next
circle 150,25,12
circle 150,25,11
circle 150,24,11
box 150,24,152,33
ink rgb(70,50,10),1
box 98,5,170,28
ink rgb(70,60,20),1
box 98,9,168,23
for i= 1 to 50
line 165,5+i/3,250,10+i
next
get image 23,0,0,250,80,1
rem red cross
ink rgb(255,255,255),1
box 0,0,100,100
ink rgb(255,0,0),1
box 10,40,90,60
box 40,10,60,90
get image 24,0,0,100,100,1
rem GUNMAN TEXTURE =============================================================
rem ==============================================================================
ink rgb(80,60,30),1:box 0,0,100,50:ink rgb(90,80,50),1
for i= 1 to 100 step 5
line 0+i,0,0+i,50
line 0,0+i,100,0+i
next
ink rgb(0,0,0),1
box 0,50,100,100
rem piece of texture to form the arms with a second sphere
get image 100,0,0,50,100,1
ink rgb(80,80,80),1 `|
box 0,50,100,100 `|
box 10,0,15,50 `| braces
box 85,0,90,50 `|
box 35,0,40,50 `|
box 60,0,65,50 `|
ink rgb(40,40,40),1
line 10,0,10,50
line 15,0,15,50
line 85,0,85,50
line 90,0,90,50
line 35,0,35,50
line 40,0,40,50
line 60,0,60,50
line 65,0,65,50
for i= 0 to 100 step 5
line 0,50+i,100,50+i
line 0+i,50,0+i,100
next
get image 101,0,0,100,100,1 rem Tshirt
get image 102,0,50,50,100,1 rem trousers
ink rgb(60,30,10),1
box 0,0,10,10
get image 103,0,0,10,10
rem hat colour
ink rgb(60,30,10),1
box 0,0,100,30
rem head
ink rgb(100,90,90),1
box 0,30,100,100
rem eyes and moustache
ink rgb(10,10,10),1
for i= 1 to 6
circle 38+i,40,1
circle 52+i,40,1
line 50,50+i,40,60+i
line 50,50+i,60,60+i
next
get image 104,0,0,100,100
ink rgb(100,90,90),1
box 0,0,20,20
get image 105,0,0,20,20
ink rgb(60,60,60),1
box 0,0,50,50
get image 106,0,0,50,50 rem gray
ink rgb(0,255,0)
box 0,0,10,10 rem green
get image 107,0,0,10,10
ink rgb(20,20,20),1
box 0,0,10,10 rem dark gray
get image 1000,0,0,10,10,1
rem bullets
cls
for i= 1 to 20
ink rgb(100+i,50+i*3,0),0
line 10+i,20,10+i,100
next
ink rgb(0,0,0)
for i=1 to 10
ellipse 20,35,9+i,15+i
next
for i= 1 to 20
ink rgb(100+i,50+i*3,0),0
line 10+i,40,10+i,100
next
get image 90,0,0,50,100,1
for i= 1 to 10
sprite i,150+10*i,710,90:scale sprite i,50
hide sprite i
next
bullets=330
rem Notice texture
ink rgb(255,255,255),1
box 0,0,500,20
ink rgb(0,0,0),1
box 0,6,10,14
for i= 1 to 6
ellipse 9,10,i,i
next
ink rgb(100,100,255),1
line 0,18,500,18
line 90,0,90,20
get image 30,0,0,500,20,1
ink rgb(0,0,0)
box 0,0,200,200
ink rgb(90,0,0),1
set cursor 5,5:print "That´s all for now...."
get image 31,0,0,170,25,1
rem cantina door
ink rgb(70,50,10),1
box 0,0,10,50
ink rgb(10,5,0),1
line 1,0,1,50
get image 555,0,0,10,50,1
rem crosshair texture
cls
ink rgb(255,255,255),1
box 0,9,20,11
box 9,0,11,20
get image 2000,0,0,20,20,1
rem Key texture
for i= 1 to 50
ink rgb(50+i*2,30+i*2,0),1
line 0+i,0,0+i,30
next
get image 444,0,0,50,30,1
cls
ink rgb(255,255,0),1
for i=1 to 5
ellipse 15,15,9-i,12-i
next
box 20,12,40,17
box 40,12,44,20
get image 445,0,0,50,30,1
rem compass texture
cls
ink rgb(255,255,255),1
for i= 1 to 100 step 2
line i,40,i,70
next i
ink rgb(155,0,0),1
for i=49 to 50
line i,0,i,100
next i
ink rgb(255,255,0),1
get image 800,0,0,100,100,1
rem enemy indicator
cls
for i= 1 to 4
ink rgb(0,255,0),1
ellipse 10,50,i,i
next
get image 820,0,0,100,100,1
rem scarecrow
cls
ink rgb(40,30,20),1
for i= 1 to 30
line 70,100+rnd(10),rnd(5),110-i+rnd(5)
line 180,100+rnd(10),220+rnd(5),110-i+rnd(5)
line 110+rnd(20),115,100+i,rnd(15)
next
ink rgb(30,20,0),1
box 75,300,160,320
box 110,100,120,300
ink rgb(20,20,20),1
for i= 1 to 120
circle 50+i,100,15
circle 115,110+i/1.5,30
circle 100-i/10,200+i/1.5,13
circle 130+i/10,200+i/1.5,13
next
get image 980,0,0,223,331,1
rem sign
cls
ink rgb(155,155,0),1
set cursor 0,0
print "CHAFARI`S PLACE"
ink rgb(0,0,0),1
for i= 1 to 300
dot rnd(120),rnd(30)
next
get image 1300,0,0,120,20,1
rem wanted texture
cls
ink rgb(255,255,255),1
box 0,0,100,150
ink rgb(30,50,80),1
for i= 1 to 40
ellipse 50,150,i,i*2
ellipse 50,151,i,i*2
next
ink rgb(130,80,70),1
for i= 1 to 20
ellipse 50,60,i,i*1.5
ellipse 50,61,i,i*1.5
next
ink rgb(80,40,40),1
for i= 1 to 30
ellipse 50,50,i*1.2,i/5
next
ink rgb(150,0,0),1
set text size 40
set cursor 2,108:print "WANTED"
ink rgb(0,0,0),1
for i= 1 to 100
dz=rnd(3)
line 0+i,65-i/3+dz,3+i,125-i/5-dz
line 0+i,64-i/3+dz,3+i,124-i/5-dz
next
get image 1301,0,0,100,150,1
`////////////////////////////////////////////////////////////////////////////
`/////////////////// SOME VARIABLES /////////////////////////////////////////
gira#=45 :avance=2 :vol=120 :suavizado=5:jugad=20 `player controls
wp=801 `2d enemy way points
state=1 `first enemy starting state
state2=1 `2d enemy starting state
sp#=0.5 `2d enemy speed
rem v=0
rem third enemy starting position
ox#=3627
oz#=1726
enemy=100
st=1 rem fourth enemy state
Distance=1000
got_key=0
dog_st=1 rem gog starting state
set camera range 10,25000
rem meshes to form the pine tree
for i= 1 to 15
make object cone i,20
position object i,0,i,0
scale object i,100-i*6,20,100-i*6
rotate object i,rnd(15),rnd(45),rnd(15)
make mesh from object i,i
delete object i
next i
`==================== PLAYER ====================
make object cylinder jugad,60
scale object jugad,100,5,100
position object jugad,x#,y#,z#
make object box 333,3,3,3 `to get direction ot enemy 1
make object box 334,25,25,0 `to show in the ring, where the enemy goes
texture object 334,820:set object 334,1,1,1 :ghost object on 334
lock object on 334:position object 334,-93,-63,130
rem ================ LEVEL ======================
make object sphere 1,5000,10,10
scale object 1,400,5,400
xrotate object 1,2
lock vertexdata for limb 1,0
for i = 0 to 11
x# = get vertexdata position x(i)
y# = get vertexdata position y(i)
z# = get vertexdata position z(i)
set vertexdata position i,x#,y#+50000,z#
next i
set vertexdata position 33,x#+10,y#+18600,z#+1000
texture object 1,3:scale object texture 1,15,15
set object collision to polygons 1
unlock vertexdata
set object normals 1
set light mapping on 1,15
make object sphere 900,300,4,4:texture object 900,3
position object 900,3313,150,873:scale object 900,70,100,70
zrotate object 900,10:set light mapping on 900,15
clone object 901,900:scale object 901,70,70,70
position object 901,3450,100,870
rem cantina -------------------------------------------------
make object box 2,900,500,600
make object box 3,890,500,590
position object 3,0,-2,0
perform csg difference 2,3
delete object 3
make object box 3,900,500,200
position object 3,100,-100,0
perform csg difference 2,3
delete object 3
make object box 3,100,100,700
position object 3,200,110,0
perform csg difference 2,3
delete object 3
texture object 2,1:scale object texture 2,2,3
position object 2,3000,50,2700
set object collision to polygons 2
make object plain 3,600,200
make mesh from object 16,3
delete object 3
add limb 2,1,16
delete mesh 16
offset limb 2,1,445,315,0
scale limb 2,1,100,70,100
rotate limb 2,1,0,90,0
texture limb 2,1,2
set object 2,1,1,1
set object cull 2,0
make object box 3,1,499,599 `front part of the cantina
make mesh from object 21,3
delete object 3
add limb 2,2,21
offset limb 2,2,-100,0,0
delete mesh 21
texture limb 2,2,15
rem cantina´s floor
make object box 3,898,40,598
texture object 3,1:scale object texture 3,5,5
set light mapping on 3,1
position object 3,3000,10,2700
rem cantina´s clon to make cowshed
clone object 4,2
position object 4,3859,-30,4821
yrotate object 4,90
scale limb texture 4,0,0.3,0.3
set light mapping on 4,6
offset limb 4,2,0,-500,0
rem church
make object box 6,60,30,40
texture object 6,6
scale object texture 6,1,10
make object box 30,10,10,10
make mesh from object 30,30
delete object 30
add limb 6,1,30
offset limb 6,1,-25,20,-15
add limb 6,2,30
delete mesh 30
offset limb 6,2,-25,25,-15:rotate limb 6,2,0,0,45
scale limb 6,2,70,70,99:texture limb 6,2,7
texture limb 6,1,6:scale limb texture 6,1,1,4
position object 6,1710,100,4300:yrotate object 6,-90
scale object 6,1200,1800,1200
rem cowshed middle wall
make object box 7,300,300,5
position object 7,3715,40,4836
texture object 7,1
set light mapping on 7,6
make mesh from object 5000,7
add limb 7,1,5000
offset limb 7,1,150,-50,-470
set object collision to polygons 7
texture limb 7,1,1:scale limb texture 7,1,1,3
rotate limb 7,1,0,0,90:scale limb 7,1,90,70,60
rem water WC
make object box 8,160,300,160
make object box 1000,158,296,158
position object 1000,0,0,4
perform csg difference 8,1000
delete object 1000
make object box 1000,180,5,180
make mesh from object 1000,1000
add limb 8,1,1000
delete mesh 1000
delete object 1000
offset limb 8,1,0,150,0
texture object 8,1
position object 8,3293,0,4600
set object collision to polygons 8
rem cantina water WC
clone object 9,8
position object 9,2761,120,1823
yrotate object 9,180
rem pine
make object cone 16,10
texture object 16,5:scale object texture 16,5,10
scale limb 16,0,30,250,30
for i= 1 to 15
add limb 16,i,i
offset limb 16,i,0,i,0
rotate limb 16,i,rnd(15),rnd(45),rnd(15)
texture limb 16,i,4
scale limb 16,i,100,50,100
next i
set object 16,1,1,1
set object cull 16,0
position object 16,2211,250,2456
scale object 16,3000,5000,3000
set object collision off 16
rem pine collision´s object (just a simple box)
make object box 5,50,200,50
position object 5,2211,130,2455
hide object 5
rem second pine collision object
clone object 10,5:position object 10,1494,100,3500:hide object 10
rem second pine
instance object 4000,16
scale object 4000,3000,4000,3000
position object 4000,1494,210,3500
rem horse ========================================================
`=================================================================
rem body
make object box 1600,50,20,18
make object box 1601,7,30,7
make mesh from object 1601,1601
delete object 1601
add limb 1600,1,1601 rem front leg
offset limb 1600,1,18,-25,5
add limb 1600,2,1601 rem front leg
offset limb 1600,2,18,-25,-5
add limb 1600,3,1601 rem rear leg
offset limb 1600,3,-18,-25,5
add limb 1600,4,1601 rem rear leg
offset limb 1600,4,-18,-25,-5
add limb 1600,5,1601 rem tail
offset limb 1600,5,-28,-10,0
rotate limb 1600,5,0,0,-10
scale limb 1600,5,50,100,50
rem head
delete mesh 1601
make object box 1601,20,11,11
make mesh from object 1601,1601
delete object 1601
add limb 1600,6,1601
offset limb 1600,6,40,20,0
rotate limb 1600,6,0,0,-80
rem neck
add limb 1600,7,1601
offset limb 1600,7,25,15,0
rotate limb 1600,7,0,0,30
scale limb 1600,7,170,80,80
delete mesh 1601
rem saddle
position object 1600,4429,140,1609
texture object 1600,1000:yrotate object 1600,180
scale object 1600,270,250,270
make object box 1601,50,32,50
position object 1601,4429,150,1609
texture object 1601,17
rem Dog
clone object 1602,1600
yrotate object 1602,-90
fix object pivot 1602
scale object 1602,60,60,60
texture object 1602,3
set light mapping on 1602,1000
position object 1602,2300,10,3876
make object box 936,2,2,13
make mesh from object 936,936
add limb 1602,8,936:offset limb 1602,8,40,22,0
rotate limb 1602,6,0,0,-30
rem =========================================================================
`============================================================================
rem fense |-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----
fense(17):position object 17,2278,80,1968:yrotate object 17,50
fense(18):position object 18,limb position x(17,1),limb position y(17,1),limb position z(17,1)
fense(19):position object 19,limb position x(18,1),limb position y(18,1),limb position z(18,1)
fense(21):position object 21,limb position x(19,1),limb position y(19,1),limb position z(19,1)
yrotate object 21,-90
fense(22):position object 22,limb position x(21,1),limb position y(21,1)-15,limb position z(21,1)
fense(23):position object 23,object position x(22),object position y(22)-20,object position z(22)+400
fense(24):position object 24,object position x(23),object position y(23)-30,object position z(23)
yrotate object 24,-90
fense(25):position object 25,limb position x(24,1),limb position y(24,1)-30,limb position z(24,1)
yrotate object 25,-90
fense(26):position object 26,object position x(17),object position y(17)-30,object position z(17)
yrotate object 26,235
fense(27):position object 27,limb position x(26,1),limb position y(26,1)-30,limb position z(26,1)
yrotate object 27,238
fense(28):position object 28,limb position x(27,1),limb position y(27,1)-20,limb position z(27,1)
yrotate object 28,243
fense(29):position object 29,limb position x(28,1),limb position y(28,1)-20,limb position z(28,1)
yrotate object 29,-45
fense(30):position object 30,limb position x(29,1),limb position y(29,1)-20,limb position z(29,1)
yrotate object 30,-30:scale object 30,600,300,300
fense(31):position object 31,limb position x(30,1),limb position y(30,1),limb position z(30,1)
yrotate object 31,15
fense(32):position object 32,limb position x(31,1),limb position y(31,1),limb position z(31,1)
yrotate object 32,15:scale object 32,550,300,300
fense(33):position object 33,limb position x(32,1),limb position y(32,1)+30,limb position z(32,1)
yrotate object 33,-90:scale object 33,550,300,300
fense(34):position object 34,limb position x(33,1),limb position y(33,1),limb position z(33,1)
scale object 34,400,300,300
fense(35):position object 35,limb position x(34,1),limb position y(34,1)-30,limb position z(34,1)
scale object 35,820,300,300
fense(36):position object 36,limb position x(25,1),limb position y(25,1)-25,limb position z(25,1)
yrotate object 36,-90
scale object 36,1008,300,300
rem |-----|-----|-----|-----|-----|-----|-----|-----|-----||-----|-----|-----|-----|-----
rem pergola de la cantina =========================================================
make object box 50,object size x(2)/6,5,object size z(2):texture object 50,1
position object 50,3525,230,2700:zrotate object 50,-5:scale object texture 50,1,6
make object box 51,8,300,8:position object 51,3587,78,2986:texture object 51,1
clone object 52,51:position object 52,3587,78,2805:texture object 52,1
clone object 53,51:position object 53,3587,78,2595:texture object 53,1
clone object 54,51:position object 54,3587,78,2412:texture object 54,1
rem sign on pergola "saloon"
make object plain 55,400,80
texture object 55,16:position object 55,3453,300,2699
yrotate object 55,90
rem ==================================================================================
rem white door
make object plain 56,150,240
texture object 56,19
set object 56,1,1,1
position object 56,1839,110,3937
set object cull 56,0
set object collision off 56
set light mapping on 56,19
rem windows
clone object 57,56
set light mapping on 57,19
scale object 57,70,70,0
yrotate object 57,-90
position object 57,1951,136,4155
rem second windows
clone object 58,57
position object 58,1951,136,4500
rem -----------------------------------------------------------------------------
rem bar bottles
make object box 59,60,130,400
position object 59,3030,80,2798
texture object 59,1
make object box 60,70,10,410
position object 60,3030,139,2788
texture object 60,17
make object plain 61,12,35
texture object 61,13:set object 61,1,1,1
position object 61,3035,160,2744
set object cull 61,0
clone object 62,61
position object 62,3036,160,2764
set light mapping on 62,15
rem GUNMAN ================================================================
`==========================================================================
make object sphere 101,10,10,10:scale object 101,90,100,30
make object sphere 102,10,10,10:scale object 102,60,100,50
make object sphere 103,3.3:offset limb 103,0,0,6,0:scale limb 103,0,70,100,80
make object box 104,2,5,2:offset limb 104,0,-1.2,-5,0:scale object texture 104,0.3,0.6
clone object 105,104:offset limb 105,0,1.2,-5,0
make object sphere 106,6,6,6:scale object 106,40,20,60:offset limb 106,0,-3,-39,-1
clone object 107,106:offset limb 107,0,3,-39,-1
clone object 108,106:offset limb 108,0,0,34,0:scale limb 108,0,250,30,200
make object box 109,1,1,4:offset limb 109,0,-3,0,-1.5 :rotate object 109, -20,-20,0
clone object 110,109:offset limb 110,0,3.2,0.4,-1:rotate object 110,-85,-5,0
make object box 111,0.3,0.3,4:offset limb 111,0,-1.8,-1,-5
make object box 112,0.2,1,0.5:offset limb 112,0,-1.8,-1.4,-4.3
make object box 113,7,7,0:make mesh from object 113,113:delete object 113
rem converting object to mesh and constructing gunman
for i= 101 to 112
make mesh from object i,i
delete object i
next i
make object box 100,1,1,1
for i= 1 to 12
add limb 100,i,i+100
next i
add limb 100,13,113:offset limb 100,13,-2.5,-1,-8:texture limb 100,13,22
texture limb 100,1,100
texture limb 100,2,101
texture limb 100,3,104
texture limb 100,4,102
texture limb 100,5,102
texture limb 100,6,103
texture limb 100,7,103
texture limb 100,8,103
texture limb 100,9,105
texture limb 100,10,105
texture limb 100,11,106
texture limb 100,12,106
set object 100,1,1,1
position object 100,2110,40,4235
scale object 100,800,800,800
yrotate object 100,180:fix object pivot 100
set object cull 100,0
rem ---- dumy -------------------------------------
rem search object
make object box 105,50,50,50
position object 105,2164,40,3136
hide object 105
rem destination object
make object box 106,50,50,50
position object 106,3164,40,4000
hide object 106
rem point object to slow enemy movements
make object box 107,50,50,50
set object collision off 107
hide object 107
rem enemy won´t see us from back
make object box 110,30,30,30:hide object 110
rem --------------------------------------------------
rem second enemy
clone object 108,100:position object 108,4937,100,2328
scale object 108,800,800,800
rem 2d enemy way points
make object box 801,10,10,10:position object 801,2000,100,3800
make object box 802,10,10,10:position object 802,1300,100,3800
make object box 803,10,10,10:position object 803,1367,70,4671
make object box 804,10,10,10:position object 804,1589,70,4855
make object box 805,10,10,10:position object 805,2047,60,4822
make object box 806,10,80,10:position object 806,2200,100,3800
for i= 801 to 806:hide object i:next i
rem fourth enemy
clone object 109,100:position object 109,4476,90,2669
hide limb 109,13
rem boxes
make object box 120,40,40,40:texture object 120,1
set light mapping on 120,18:position object 120,3620,74,1691
clone object 121,120:position object 121,3627,74,1746:yrotate object 121,30
clone object 122,120:position object 122,3627,115,1726
clone object 123,120:position object 123,3627,158,1726:yrotate object 123,20
clone object 126,120:position object 126,4500,80,1530
clone object 127,120:position object 127,3867,-50,4786
rem big box close water
clone object 128,120:position object 128,3100,0,4860
scale object 128,200,230,200:scale object texture 128,2,2
clone object 129,128:position object 129,4110,-20,4700 `boxes into the cowshed
set object emissive 129,rgb(0,60,0)
clone object 130,129:position object 130,4110,72,4700:yrotate object 130,10
rem third enemy position (sensor)
make object box 124,20,200,20:offset limb 124,0,0,0,-200
position object 124,3627,120,1726 :hide object 124
rem third enemy
clone object 125,100
rem fourth enemy way points
make object box 810,30,30,30:hide object 810
position object 810,3513,100,2702
offset limb 810,0,0,-100,0
make object box 811,30,30,30 rem enemy don´t see from back
hide object 811
rem GUN ===========================================================
make object cylinder 518,5
make mesh from object 518,518
add limb 518,1,518
offset limb 518,1,-5,0,0
scale object 518,10,150,10
make object box 519,10,2,6
make mesh from object 519,519
add limb 518,2,519
offset limb 518,2,-2.5,-2,0
add limb 518,3,518
offset limb 518,3,-2,-3.5,-1
delete object 519
scale limb 518,3,150,100,150
xrotate object 518,90:fix object pivot 518
texture object 518,20
texture limb 518,2,15
lock object on 518
position object 518,10,-8,17
set light mapping on 518,6
hide object 518 rem player start without gun
rem ==============================================================
rem WATER TANK -----------------------------------------------------
make object cylinder 201,10
scale object 201,100,200,100
make object box 202,20,10,20
position object 202,0,-4,0
make mesh from object 201,201
save mesh "pa_borrar.x",201
delete object 201
delete mesh 201
load object "pa_borrar.x",201
perform csg difference 201,202
delete object 202
position object 201,3000,250,1000
set object collision off 201
make object box 202,0.5,10,0.5
make mesh from object 202,202
add limb 201,1,202:offset limb 201,1,-6,-3,0:rotate limb 201,1,0,0,-10
add limb 201,2,202:offset limb 201,2,6,-3,0:rotate limb 201,2,0,0,10
add limb 201,3,202:offset limb 201,3,0,-3,6:rotate limb 201,3,-10,0,0
add limb 201,4,202:offset limb 201,4,0,-3,-6:rotate limb 201,4,10,0,0
texture object 201,1
scale object texture 201,1,3
scale object 201,2300,3000,2300
yrotate object 201,45
rem flyes -----------------------------------------------------------
make object box 1001,10,10,10
set object collision off 1001
hide object 1001
for i= 1002 to 1006
make object plain i,0.5,0.5
set object cull i,0
texture object i,9
next i
rem cactus -----------------------------------------------------------
make object plain 1007,200,300
texture object 1007,11
set object 1007,1,1,1
position object 1007,3592,250,0
set object cull 1007,0
clone object 1008,1007
position object 1008,3421,220,532
clone object 1009,1007
position object 1009,5673,271,-1800
clone object 1010,1007
position object 1010,5389,320,-1800:scale object 1010,150,150,150
clone object 1011,1007:position object 1011,8009,90,2300
clone object 1012,1007:position object 1012,2755,260,5963:scale object 1012,70,70,70
rem bottles
make object plain 1050,200,40
texture object 1050,12
yrotate object 1050,-90
position object 1050,2905,230,2900
scale object texture 1050,3,1
set object 1050,1,1,1
clone object 1051,1050
position object 1051,2905,180,2900
set light mapping on 1051,14
clone object 1052,1050
position object 1052,2905,230,2660
rem mountains
for i= 1 to 4
make object cone i+600,12000
scale object i+600,100,20,100
yrotate object i+600,45*i
texture object i+600,3
set object collision to polygons i+600
position object i+600,3000,920,2000
move object i+600,11000
next i
scale object 601,200,30,200:move object 601,4000
scale object 602,155,45,155:move object 602,2000:move object down 602,100
scale object 604,155,30,155
rem starting player position
x#=3316
y#=50
z#=4569
rem yrotate camera 180
rem level borders
make object sphere 17000,10000,5,5
set object cull 17000,0
position object 17000,4000,0,2000
set object collision to polygons 17000
color object 17000,rgb(0,0,255)
ghost object on 17000
hide object 17000
rem bar`s lamp
make object sphere 17001,50,5,5
scale object 17001,100,50,100
set object light 17001,500
position object 17001,3280,290,2730
rem glass windows ====================================================
make object box 400,103,103,1
position object 400,3200,160,2997
texture object 400,21
set object 400,1,1,1
scale object texture 400,3,3
clone object 401,400:position object 401,3200,160,2403
clone object 402,400:ghost object on 402:texture object 402,3:scale object texture 402,0.5,0.5
clone object 403,401:ghost object on 403:texture object 403,3:scale object texture 403,0.5,0.5
rem ==========================================================================================
rem gun on bar
make object box 500,0,15,100:texture object 500,23:set object 500,1,1,1
position object 500,3034,150,2633:set object light 500,20:xrotate object 500,-5
rem health box
make object box 501,20,10,20:texture object 501,24:position object 501,4555,60,1527
clone object 502,501:position object 502,2962,40,2926:yrotate object 502,20
clone object 503,501:position object 503,3716,-60,4905
rem notice on the wall
make object box 2000,10,15,0
make mesh from object 2000,2000
add limb 2000,1,2000:offset limb 2000,1,0,0,-0.1
texture object 2000,30:scale object texture 2000,1,20
set object 2000,1,1,1
texture limb 2000,1,31:scale limb texture 2000,1,1,0.05
scale limb 2000,1,90,10,90
rotate limb 2000,1,0,0,40
position object 2000,3724,60,4842
yrotate object 2000,180:zrotate object 2000,-5
scale object 2000,200,200,200
rem sign
make object plain 2001,300,60:texture object 2001,1300
set object 2001,1,1,1:position object 2001,3178,240,3001
set object cull 2001,0:scale object 2001,-100,200,200
rem all blood (when we die looks all red)
make object sphere 25005 ,50,5,5:texture object 25005,7
set object collision off 25005:set object cull 25005,0
set alpha mapping on 25005,80
hide object 25005
sky=25006 `sky sphere
make object sphere sky,35000,:texture object sky,500: set object cull sky,0
set object collision off sky :xrotate object sky,100:ghost object on sky
zrotate object sky,30 :scale object sky,130,100,130:position object sky,0,-5000,0
color backdrop rgb(100,100,255)
set object emissive sky,rgb(170,100,50)
rem ===============================================================================
rem cantina`s door ================================================================
make object box 91,20,10,1
make object box 92,30,20,3
position object 92,-10,11,0
zrotate object 92,15
perform csg difference 91,92
delete object 92
offset limb 91,0,10,0,0
texture object 91,555:scale object texture 91,10,1
position object 91,3445,110,2600:yrotate object 91,-90:fix object pivot 91
scale object 91,500,900,300:set object collision off 91
clone object 92,91
position object 92,3445,110,2800:yrotate object 92,180:fix object pivot 92
rem cantina`s door sensor
make object box 93,20,20,20:position object 93,3435,-100,2701
rem cowsheh rail door
make object box 94, 420,10,10:position object 94,3775,130,4366
texture object 94,20
rem Key
make object box 95,50,25,0
texture object 95,444:set light mapping on 95,445:set object light 95,10
position object 95,3385,100,787:set object 95,1,1,1
rem compas
make object sphere 96,20,20,20
scale object 96,70,0,70
xrotate object 96,90
texture object 96,800: set object 96,1,1,1
lock object on 96
position object 96,-68,-46,95
make object cone 97,2:offset limb 97,0,0,1,0
scale limb 97,0,100,130,1
make mesh from object 97,97
add limb 97,1,97:rotate limb 97,1,0,0,180:offset limb 97,1,0,-0.6,0
lock object on 97:scale object 97,50,200,50
position object 97,-64.5,-43.5,90:texture limb 97,1,1000
rem rat
make object sphere 411,5,4,4
scale object 411,40,40,100
make object cone 412,5
scale limb 412,0,25,140,25
make mesh from object 412,412
delete object 412
add limb 411,1,412:rotate limb 411,1,-90,0,0
offset limb 411,1,0,0,-3
position object 411,3437,100,819
yrotate object 411,220:scale object 411,200,300,600
texture object 411,20:set light mapping on 411,20
rem scarecrow
make object box 630,90,150,1
texture object 630,980:set object 630,1,1,1:position object 630, 7505,140,1203
rem wanted notice on wall
make object plain 631,40,80:texture object 631,1301
position object 631,3359,170,2393:set object 631,1,1,1
set object cull 631,0
rem ===============================================================================
`SOME SOUNDS
`based on Ric's original code and modified to use memblocks by Green Gandalf
createsound("enemy_shoot",1,1200,20,8000,0.7,10,0.00,0,0.00,0,5)
createsound("player_shoot",2,1200,70,8000,0.7,10,0.00,0,0.00,0,5)
createsound("cricket1",3,4500,30,1000,0.01,1,0.00,0,0.00,0,5)
createsound("cricket2",4,4000,30,1000,0.01,1,0.00,0,0.00,0,5)
createsound("dog",5,50,100,2500,-0.1,-0.2,-0.1, 235,0.6,0,10)
createsound("sliding_door",6,380,389,8000,7.55,5.49,0,20,0,0,4.46)
set sound speed 6,8000
set sound speed 5,8000
color backdrop rgb(30,10,0)
set ambient light 20
rem hide light 0
set text font "Perpetua"
set text size 40
do
`enemy position indicator
zrotate object 334,-object angle y(333)+gira#+270
point object 95,x#,camera position y(),z# `key object
RANDOMIZE TIMER()
rem cricket sounds
if rnd(10)=1 then play sound 3
if rnd(200)=1 then set sound volume 3,0
if rnd(200)=30 then set sound volume 3,100
if rnd(20)=1 then play sound 4
if rnd(200)=10 then set sound volume 4,0
if rnd(200)=100 then set sound volume 4,100
rem player bullets
if loaded=1
for i= 1 to 10
if bullets>i*30 then show sprite i else hide sprite i
next
endif
`//////////////////////////// PLAYER SHOOT ////////////////////////////
if mouseclick() and loaded=1 and bullets>30
sh=sh+1
if sh=1
xrotate object 518,-15
play sound 2
bullets=bullets-2
endif
if sh=5 then xrotate object 518,0
endif
if mouseclick()=0 then sh=0:if bullets=30 then xrotate object 518,0
`//////////////////////////////////////////////////////////////////////
rem player take a health box
if health<-150
if dist(x#,z#,501)<50 then health=health+150:position object 501,55000,0,5000 rem just to get it away
endif
if health<-150
if dist(x#,z#,502)<50 then health=health+150:position object 502,55100,0,5000
endif
if health<-150
if dist(x#,z#,503)<50 then health=health+150:position object 503,53100,0,5000
endif
rem player get the gun
if dist(object position x(500),object position z(500),jugad)<70
hide object 500
show object 518
loaded=1
for i= 1 to 10 :show sprite i:next
endif
`crosshair
if health>-416 and loaded=1 then sprite 1000,512,384,2000
rem checking if enemy is in the cross hairs
if object screen x(100)>490 and object screen x(100)<530 and object screen y(100)>366 and object screen y(100)<402
if mouseclick() and loaded=1
if dist(x#,z#,105)<950 and rnd(10)=1 and d=1 then enemylife=enemylife-rnd(3)
endif
endif
if enemylife<-20 then state=4 `enemy dies
rem hiding limb fire of enemies
hide limb 100,13
hide limb 108,13
hide limb 125,13
rem blood object
position object 25005,camera position x(),camera position y(),camera position z()
rem player´s health bar
ink rgb(155,0,0),1
box 300,730,724,760
ink rgb(0,155,0),1
box 302,732,722+health,758
rem we die
if health<-416
health=-416
show object 25005
rotate camera 0,object angle y(105)-180,-90
hide object 518 rem player gun
endif
if health=-416
set text size 100:
text 270,350, "GAME OVER ":hide all sprites
set sound volume 1,0
endif
rem hiding enemy behaviour ººººººººººººººººººººººººººººººººººººººººººººººººº
f=rnd(10)
pos1=limb position x(124,0)
if rnd(30)=1 then yrotate object 124,object angle y(124)-5+rnd(10)
pos2=limb position x(124,0)
if rnd(30)=1 then yrotate object 124,object angle y(124)-5+rnd(10)
if dist(x#,z#,125)<1200
point object 124,x#,object position y(124),z#
point object 125,x#,object position y(125),z#
rotate limb 125,4,0,0,f
rotate limb 125,5,0,0,-f
endif
lx#=limb position x(124,0)
lz#=limb position z(124,0)
if ox#<lx# then inc ox#
if ox#>lx# then dec ox#
if oz#<lz# then inc oz#
if oz#>lz# then dec oz#
position object 125,ox#,120,oz#
if pos1<>pos2 then rotate limb 125,4,0,0,f:rotate limb 125,5,0,0,-f
if dist(x#,z#,124)<150 then inc side,15:if side>140 then side=140
if dist(x#,z#,124)<200 then dec side,1:if side<0 then side=0
if dist(x#,z#,124)<150 then offset limb 124,0,side,0,100
if dist(x#,z#,124)>200 then offset limb 124,0,0,0,-200
`if we aproach to much ..the enemy will shoot us
if dist(x#,z#,125)<600
tmp=tmp+1
if tmp>80 then tmp=0
if tmp<3 then show limb 125,13:play sound 1:if rnd(2)=1 then health=health-rnd(5)
rotate limb 125,13,0,0,rnd(180)
endif
if dist(x#,z#,125)<200
tmp=tmp+1
if tmp>50 then tmp=0
if tmp<3 then show limb 125,13:play sound 1:if rnd(2)=1 then health=health-rnd(20)
rotate limb 125,13,0,0,rnd(180)
endif
if dist(x#,z#,125)<1200
if rnd(1000)=1 then play sound 1 `playing sound just to scare the player
endif
rem ºººººººººººººººººººººººººººººººººººººººººººººººººººººººººººººººººººººººº
rem checking intersect with objects in the scene --------
nx=object position x(105)
ny=object position y(105)
nz=object position z(105)
d=1
for i= 2 to 10
if object exist(i)
if intersect object(i,x#,y#+30,z#,nx,ny,nz)>0 then d=0
endif
next i
rem --------------------------------------------------------
REM RANDOMIZE TIMER()
delay= 40
rem dumy movements
position object 110,object position x(105),object position y(105)+30,object position z(105)
if state=1
move object 105,speed#
ang#=object angle y(105)
point object 105,object position x(106),object position y(106),object position z(106)
new_ang#=object angle y(105)
finalang#=curveangle(new_ang#,ang#,delay)
yrotate object 105,finalang#
if object collision(105,106)>0 then position object 106,2164+rnd(2200),0,3136+rnd(1300)
if object collision(106,1)=1 then move object up 106,1 else move object down 106,1
position object 100,object position x(105),object position y(105)+30,object position z(105)
yrotate object 100,finalang#
position object 107,object position x(105),object position y(105)+30,object position z(105)
point object 107,object position x(106),object position y(107),object position z(106)
rem speed control
a1=object angle y(107)
a2=object angle y(105)
if a1<>a2 then speed#=0.2 else speed#=0.5
if dist(x#,z#,105)<900 and d=1 and front=1 then state=2
rem if we shoot the enemy, he will face the player
if mouseclick() and loaded=1
if dist(x#,z#,105)<distance
state=3
endif
endif
endif
rem enemy won`t see us from back
position object 110,object position x(105),object position y(105)+30,object position z(105)
move object 110,-40:yrotate object 110,ang#
if dist(x#,z#,105)<dist(x#,z#,110)-25 then front=1 else front=0
if state=2
point object 105,object position x(20),object position y(105),object position z(20)
position object 100,object position x(105),object position y(105)+30,object position z(105)
if dist(x#,z#,105)>200 then move object 105,0.5
yrotate object 100,object angle y(105)
yrotate object 110,object angle y(105) rem chivato espalda
rem Enemy shoot
if dist(x#,z#,105)<distance and d=1 and front=1
tmp=tmp+1
if tmp<3 then show limb 100,13:play sound 1:if rnd(2)=1 then health=health-rnd(20)
if tmp>60 then tmp=0
rotate limb 100,13,0,0,rnd(180)
endif
if dist(x#,z#,105)>distance and d=1 then state=3
if d=0 then state=1
endif
if dist(x#,z#,105)<200 and d=1 then state=3 `we atack from back
rem -------------------------------
if state=3
point object 105,object position x(20),object position y(105),object position z(20)
position object 100,object position x(105),object position y(105)+30,object position z(105)
yrotate object 100,object angle y(105)
yrotate object 110,object angle y(105) rem enemy back sensor
speed#=0
if d=0 and rnd(50)=1 then state=1
if dist(x#,z#,105)<800 and d=1 then state=2
if dist(x#,z#,105)>distance then state=1
if d=0 then state=1
endif
rem ------------------------------
if state=4
s=s+2
if s>90 then s=90
xrotate object 100,s
position object 100,object position x(100),object position y(100)-0.4,object position z(100)
endif
rem if enemy dies...come another one
if object position y(100)<0
position object 105,1844,10,4042
position object 106,1882,40,3486
rotate object 100,0,0,0
state=1
enemylife=0
endif
rem get away from dog
if object collision(105,1602)>0 then position object 106,2164+rnd(2200),0,3136+rnd(1300)
if object collision(105,1602)>0 then move object 1602,-5
rem dog movements
if state<4 and dog_st=1
point object 1602,object position x(enemy),object position y(105),object position z(enemy)
if dist(object position x(1602),object position z (1602),105)>enemy
move object 1602,0.4
rotate limb 1602,1,0,0,-20+rnd(40):rotate limb 1602,2,0,0,-20+rnd(40)
rotate limb 1602,3,0,0,-20+rnd(40):rotate limb 1602,4,0,0,-20+rnd(40)
if dist(x#,z#,1602)<300 then dog_st=2
endif
endif
rem dog`s tail
rotate limb 1602,5,-10+rnd(20),0,-20-rnd(20)
if dog_st=2
if rnd(30)=1 then play sound 5:set sound speed 5,8000+rnd(1000)
point object 1602,x#,object position y(1602),z#
if dist(x#,z#,1602)>100
move object 1602,0.4
rotate limb 1602,1,0,0,-20+rnd(40):rotate limb 1602,2,0,0,-20+rnd(40)
rotate limb 1602,3,0,0,-20+rnd(40):rotate limb 1602,4,0,0,-20+rnd(40)
endif
if dist(x#,z#,1602)<200 then state=2
if dist(x#,z#,1602)>300 then dog_st=1
endif
rem second enemy movements among way points
if state2 =1
point object 806,object position x(wp),object position y(wp),object position z(wp)
if object collision(806,801)>0 then wp=802
if object collision(806,802)>0 then wp=803
if object collision(806,803)>0 then wp=804
if object collision(806,804)>0 then wp=805
if object collision(806,805)>0 then wp=801
move object 806,sp#
position object 108,object position x(806),object position y(806)-60,object position z(806)
yrotate object 108,object angle y(806)
endif
if dist(x#,z#,806)<300 then state2=2
rem ------------------
if state2=2
point object 806,object position x(20),object position y(806),object position z(20)
position object 108,object position x(806),object position y(806)-60,object position z(806)
yrotate object 108,object angle y(806)
move object 806,sp#
if dist(x#,z#,806)<200 then sp#=0 else sp#=0.5
if dist(x#,z#,806)<600
tmp=tmp+1
if tmp>60 then tmp=0
if tmp<3 then show limb 108,13:play sound 1:if rnd(2)=1 then health=health-rnd(20)
rotate limb 100,13,0,0,rnd(180)
endif
if dist(x#,z#,806)>600 then state2=1
endif
rem -------------------------------------------------------------------------------------------
rem fourth enemy movements
if intersect object(2,x#,y#,z#,object position x(109),object position y(109),object position z(109))>0
tb=0 `enemy don`t see us
else
tb=1 `enemy see us
endif
rem STATE 1
if st=1
point object 109,object position x(810),object position y(810),object position z(810)
move object 109,0.4
`every time the enemy collision with object 810, it change to different position and will make the enemy face to it
if object collision(109,810)>0 and object position x(810)<4000 then position object 810,4476,90,2669
if object collision(109,810)>0 and object position x(810)>3000 then position object 810,3513,100,2702
position object 811,object position x(109),object position y(109),object position z(109)
move object 811,-40:set object to object orientation 811,109
if dist(x#,z#,109)<distance and tb=1
if dist(x#,z#,109)<dist(x#,z#,811)-20 then st=2
endif
endif
if dist(x#,z#,109)<200 and tb=1 then st=2 `we atack from back.variable tb=1 in order not to be seen behind objects
hide limb 109,13 `lim that shows the gun fire
rem STATE 2
oxt=object position x(109)
ozt=object position z(109)
if st=2
if tb=1
if dist(x#,z#,109)<distance
if dist(x#,z#,109)<distance and oxt>3547 then move object 109,0.4:if oxt>4590 then move object 109,-1
tmp=tmp+1
if tmp>60 then tmp=0
if tmp<3 then show limb 109,13:play sound 1:if rnd(2)=1 then health=health-rnd(20) `if we aproach to much ..the enemy shoot us
rotate limb 109,13,0,0,rnd(180)
point object 109,x#,object position y(109),z#
if dist(x#,z#,109)>200 and oxt>3547 then move object 109,0.4 `enemy atack
endif
endif
position object 811,object position x(109),object position y(109),object position z(109)
move object 811,-40:set object to object orientation 811,109
if dist(x#,z#,109)>distance then st=1 `if we run away, the enemy state chage to pasive
if tb=0 then st=1 `if we are hide into the bar then st=1
endif
rem checking if enemy is in the cross hairs
if object screen x(109)>482 and object screen x(109)<542 and object screen y(109)>334 and object screen y(109)<434 then hit=1 else hit=0
if mouseclick() and loaded=1 and bullets>0 and hit=1 then st=3
rem if we shoot the enemy he will turn to us
if st=3
point object 109,x#,object position y(109),z#
if dist(x#,z#,109)>distance and rnd(300)=1 then st=1
if dist(x#,z#,109)<distance then st=2
endif
rem checking if fourth enemy is in the cross hairs
if object screen x(109)>480 and object screen x(109)<520 and object screen y(109)>356 and object screen y(109)<392
if mouseclick() and loaded=1
if dist(x#,z#,109)<950 and rnd(4)=1 and d=1 then enemy_life=enemy_life-rnd(3)
endif
endif
if enemy_life<0 then st=4 `enemy dies
if st=4
s=s+1
if s>90 then s=90:position object 109,10000,-100,3000 `deep died
xrotate object 109,s
position object 109,object position x(109),object position y(109)-0.5,object position z(109)
endif
rem cantina doors ---------------------------------------
if dist(x#,z#,93)<100 and x#>3447 then cantina#=cantina#+2 `cantina`s door opens we we are in front of it
if dist(x#,z#,93)>100 and x#>3447 and cantina#>0 then dec cantina#
if cantina#>160 then cantina#=160:if cantina#<0 then cantina#=0
yrotate object 91,-cantina#
yrotate object 92,cantina#
rem flyes animation -----------------------------------------------
position object 1001 ,3254+g#*10,100+g#*10,4698+g#*10
for i= 1002 to 1006
position object i,object position x(1001)+rnd(100),object position y(1001)-100+rnd(100),object position z(1001)+rnd(100)
rotate object i,rnd(360),rnd(360),rnd(360)
next i
rem --------------------------------------------
rem animasion para el pino
m=m+1 rem timer for animation
if m<400 then g#=g#+0.002
if m>400 then g#=g#-0.002
if m>800 then m=0
for i= 1 to 15
rotate limb 16,i,g#/2,g#,g#
next i
rem --------------------------------------------
rem cactus orientation
for i= 1007 to 1010
point object i,camera position x(),object position y(i),camera position z()
next i
yrotate object 1011,camera angle y():point object 1012,x#,object position y(1012),z#
scale object 1011,100,100,-100
rem ---------------------------------------------------------------------
rem bottles on the bar
point object 61,camera position x(),object position y(61),camera position z()
point object 62,camera position x(),object position y(62),camera position z()
rem compass animation
g=rnd(3) `compass needle movements
zrotate object 97,g-1
zrotate object 96,gira#+90
rem rat movement
if dist(x#,z#,411)<180 then a=1
if a=1 then move object 411,2
rem espantapajaros
point object 630,x#,object position y(630),z#
gosub control `player`s movements control
sync
loop
control:
oldx#=x#
oldz#=z#
y#=object position y(20)
`camera control
yrotate camera camera angle y()+(mousemovex()/2)
xrotate camera camera angle x()+(mousemovey()/2)
gira#=camera angle y()
`camera limits
if camera angle x() >60 then xrotate camera 60
if camera angle x() <-45 then xrotate camera -45
`********* player movements *************
if upkey()=1 THEN x#=NEWXVALUE(x#,gira#,avance):z#=NEWZVALUE(z#,gira#,avance)
if downkey()=1 THEN x#=NEWXVALUE(x#,gira#,0-avance):z#=NEWZVALUE(z#,gira#,-avance)
`slide left
if leftkey()=1 THEN x#=NEWXVALUE(x#,gira#-90,avance):z#=NEWZVALUE(z#,gira#-90,avance)
`slide right
if rightkey()=1 THEN x#=NEWXVALUE(x#,gira#-90,0-avance):z#=NEWZVALUE(z#,gira#-90,0-avance)
for i= 1 to 10
if object exist (i)
`get floor height(coordenate y)
if INTERSECT OBJECT(i,x#,y#,z#,x#,y#-vol,z#)>0 then y#=y#+(vol-INTERSECT OBJECT(i,x#,y#,z#,x#,y#-vol,z#))/suavizado
`if not floor we fall down
if INTERSECT OBJECT(i,x#,y#,z#,x#,y#-90,z#)=0 then gravedad#=3
endif
next i
rem camera position update
position object jugad,x#+10,y#-gravedad#,z#
position camera x#,y#-gravedad#+30,z#
position object 333,x#,-200,z#
point object 333,nx,object position y(333),nz
if dist(x#,z#,95)<100 then got_key=1:hide object 95:sprite 20,110,720,445 `if we get a key, a sprite will appear on screen
direc=wrapvalue(camera angle y())
if direc>320 or direc<40 then see=1 else see=0 `checking if we face to the cowshed door
ink rgb(255,255,0),1
if object collision(jugad,7)>0 and see=1 and got_key=0 then set cursor 270,300:set text size 60:print "YOU NEED A KEY"
if object collision(jugad,7)>0 and got_key=1 then con_llave=1:hide sprite 20
if con_llave=1
opn#=opn#+0.2
loop sound 6
if opn#>190 then opn#=190:stop sound 6
offset limb 7,1,150-opn#,-50,-470
endif
`SLIDING COLLISION BASIC
`-----------------------------------
if object collision(jugad,0)>0:gosub zzol
if object collision(jugad,0)=0:z#=oldz#
endif
endif
if object collision(jugad,0)>0:gosub xxol
if object collision(jugad,0)=0:x#=oldx#
endif
endif
if object collision(jugad,0)>0
x#=oldx#:z#=oldz#
endif
return
`------------------------------------
xxol:
POSITION OBJECT jugad,oldx#+10,y#-gravedad#,z#
return
zzol:
POSITION OBJECT jugad,x#+10,y#-gravedad#,oldz#
return
function fense(obj)
make object box obj,100,40,0
offset limb obj,0,50,15,0
texture object obj,8:scale object texture obj,2,1
set object obj,1,1,1
scale object texture obj,2,1
make object box 1000,2,2,2
make mesh from object 8,1000
add limb obj,1,8
delete mesh 8
delete object 1000
offset limb obj,1,100,0,0
hide limb obj,1
scale object obj,900,300,300
endfunction
function dist(x#,z#,obj2)
dx#=object position x(obj2)-x#
dz#=object position z(obj2)-z#
dist#=sqrt((dx#*dx#)+(dz#*dz#))
endfunction dist#
function createsound(name$,soundnumber,frequency#,length#,loudness#,bend#,decay#,vibratospeed#,vibratodepth#,tremelospeed#,tremelodepth#,attack#)
` based on Ric's original code and modified to use memblocks by Green Gandalf
outWord as word
dword1 as dword: dword2 as dword: dword3 as dword: dword4 as dword
dword5 as dword: dword6 as dword: dword7 as dword
samples=int((length#/1000)*44100)
if memblock exist(1) then delete memblock 1
make memblock 1,samples*2+28
` write 28 memblock header bytes
dword1=1 ` gg query: is this the number of channels?
dword2=2 ` gg query: is this the number of bytes per sample?
dword3=22050 ` gg query: seems to be half the number of samples per second - why?
dword4=88200 ` gg query: is this the number of bytes per second?
dword5=4 ` gg query: what does this represent?
dword6=16 ` gg query: (ditto) ?
dword7=0 ` gg query: (ditto) ?
position=0
write memblock dword 1, position, dword1 : inc position,4
write memblock dword 1, position, dword2 : inc position,4
write memblock dword 1, position, dword3 : inc position,4
write memblock dword 1, position, dword4 : inc position,4
write memblock dword 1, position, dword5 : inc position,4
write memblock dword 1, position, dword6 : inc position,4
write memblock dword 1, position, dword7 : inc position,4
rem generate and write wave
`inc param_attackamount#,0.0001
riseinloudness#=loudness#
for x=1 to samples
outInteger=int(sin((x/122.5)*(frequency#+vibratodepth#*sin(theta#)))*(loudness#-fallinloudness#-riseinloudness#+tremelodepth#*sin(phi#)))*3.0
if outInteger <-32767 then outInteger=-32767 ` gg query: is this the valid range?
if outInteger>32767 then outInteger=32767 ` gg query: (ditto) ?
outWord=outInteger
inc theta#,vibratospeed#
inc phi#,tremelospeed#
dec frequency#,bend#
if fallinloudness#<loudness#
inc fallinloudness#,decay#
endif
if riseinloudness#>0
dec riseinloudness#,attack#
endif
write memblock word 1,position,outWord : inc position,2
next x
if sound exist(soundnumber)=1 then delete sound soundnumber
make sound from memblock 999, 1 ` assumes you won't need sound number 999!
clone sound soundnumber, 999
delete sound 999
` memblock no longer required
delete memblock 1
endfunction
cheers.
I'm not a grumpy grandpa