The code is updated. I got some dogs and horses into it now, but I can't get them to die. I want when the aim (called dot) goes over the image and the player clicks the mouse, the dog or horse will disappear.
Graphics 1024,768,32
SetBuffer BackBuffer()
AppTitle"Hic Hunting"
main = LoadImage("gfx/main.bmp")
While Not KeyDown(57)
Cls
If KeyHit(28) Then Goto start
DrawImage main,0,0
Flip
Wend
.start
Graphics 1024,768,32
SetBuffer BackBuffer()
AppTitle"Hic Hunting"
forestimage = LoadImage("gfx/forest.bmp")
forest2 = LoadImage("gfx/forest2.bmp")
treesimage = LoadImage("gfx/trees.bmp")
pistol = LoadAnimImage("gfx/pistol.bmp",300,300,0,2)
aimimage = LoadImage("gfx/aim.bmp")
Global dotimage = LoadImage("gfx/dot.bmp")
Global treehitimage = LoadAnimImage("gfx/tree hit.bmp",30,30,0,10)
Global barkhitimage = LoadImage("gfx/barkhit.bmp")
Global dogimage = LoadAnimImage("gfx/dog.bmp",300,300,0,22)
Global horseimage = LoadAnimImage("gfx/horse.bmp",300,300,0,22)
b1 = LoadSound("sfx/bird1.wav")
b2 = LoadSound("sfx/bird2.wav")
gun = LoadSound("sfx/gun.wav")
Type th
Field x,y,frame
End Type
Type bh
Field x,y
End Type
Type d
Field x,y,frame,image
End Type
Type h
Field x,y,frame
End Type
Type trees
Field x,y
End Type
Type forest
Field x,y
End Type
Type aim
Field x,y
End Type
Type dot
Field x,y
End Type
forest.forest = New forest
trees.trees = New trees
aim.aim = New aim
dot.dot = New dot
num = OpenFile ("screenshots/numoshot.txt")
screenhit = ReadLine(num)
CloseFile(num)
createdog1(x,y)
While Not KeyDown(1)
Cls
Gosub backgroundsounds
Gosub movement
Gosub drawimages
Gosub frames
Gosub attack
If KeyHit(18)
SaveBuffer (BackBuffer(),"screenshots/hichuntscreen" + screenhit + ".jpg")
screenhit = screenhit + 1
num = WriteFile("screenshots/numoshot.txt")
WriteLine(num),screenhit
EndIf
Flip
Wend
End
.backgroundsounds
bsound = bsound + 1
If bsound = 251 Then bsound = 0
If bsound = 1 Then PlaySound b1
If bsound = 100 Then PlaySound b1
If bsound = 150 Then PlaySound b1
Return
.frames
If pf = 1 Then pf = 0
Return
.movement
dot\x = MouseX()
dot\y = MouseY()
aim\x = MouseX() - 15
aim\y = MouseY() - 15
Return
.attack
If MouseHit(1)
PlaySound gun
pf = 1
If (ImagesCollide(dotimage,dot\x,dot\y,0,treesimage,trees\x,trees\y,0))
createhit(x,y)
EndIf
If (ImagesCollide(dotimage,dot\x,dot\y,0,forestimage,forest\x,forest\y,0))
createhit2(x,y)
EndIf
EndIf
Return
.drawimages
DrawImage forestimage,0,0
updatehit2()
DrawImage treesimage,trees\x,trees\y
updatehit()
DrawImage forest2,0,0
updatedog()
DrawImage dotimage,dot\x,dot\y
DrawImage aimimage,aim\x,aim\y
DrawImage pistol,724,468,pf
Return
Function createhit(x,y)
treehit.th = New th
treehit\x = MouseX() - 15
treehit\y = MouseY() - 15
pf = 1
End Function
Function updatehit()
For th.th = Each th
If th\frame < 9 Then th\frame = th\frame + 1
DrawImage (treehitimage,th\x,th\y,th\frame)
Next
End Function
Function createhit2(x,y)
barkhit.bh = New bh
barkhit\x = MouseX() - 15
barkhit\y = MouseY() - 15
End Function
Function updatehit2()
For bh.bh = Each bh
DrawImage (barkhitimage,bh\x,bh\y)
Next
End Function
Function createdog1(x,y)
dog.d = New d
dog\x = -3500
dog\y = 350
dog.d = New d
dog\x = -2100
dog\y = 550
dog.d = New d
dog\x = -1600
dog\y = 400
dog.d = New d
dog\x = 0
dog\y = 350
dog.d = New d
dog\x = 4524
dog\y = 350
dog\frame = 12
dog.d = New d
dog\x = 3124
dog\y = 550
dog\frame = 12
dog.d = New d
dog\x = 2624
dog\y = 400
dog\frame = 12
dog.d = New d
dog\x = 1024
dog\y = 350
dog\frame = 12
horse.h = New h
horse\x = -3500
horse\y = 350
horse.h = New h
horse\x = -2100
horse\y = 550
horse.h = New h
horse\x = -1600
horse\y = 400
horse.h = New h
horse\x = 0
horse\y = 350
horse.h = New h
horse\x = 4524
horse\y = 350
horse\frame = 12
horse.h = New h
horse\x = 3124
horse\y = 550
horse\frame = 12
horse.h = New h
horse\x = 2624
horse\y = 400
horse\frame = 12
horse.h = New h
horse\x = 1024
horse\y = 350
horse\frame = 12
End Function
Function updatedog()
For d.d = Each d
If d\frame < 10 Then d\x = d\x + 5
If d\frame > 10 Then d\x = d\x - 5
d\frame = d\frame + 1
If d\frame = 10 Then d\frame = 0
If d\frame = 21 Then d\frame = 11
DrawImage (dogimage,d\x,d\y,d\frame)
If (ImagesCollide(dotimage,dot\x,dot\y,0,d,d\x,d\y,d\frame))
EndIf
Next
For h.h = Each h
If h\frame < 10 Then h\x = h\x + 10
If h\frame > 10 Then h\x = h\x - 10
h\frame = h\frame + 1
If h\frame = 10 Then h\frame = 0
If h\frame = 21 Then h\frame = 11
DrawImage (horseimage,h\x,h\y,h\frame)
Next
End Function
|