java 狼捉羊游戏背景_Js 写了一个 “狼吃羊” 小游戏。

这篇博客介绍了作者使用JavaScript编写的一款类似于VB风格的“狼吃羊”小游戏。游戏通过键盘方向键控制羊的移动,当羊与狼的位置满足一定条件时,狼会捕食羊,玩家得分会相应变化。
摘要由CSDN通过智能技术生成

7

2019-04-14 17:12:01 +08:00

想起我最开始上学习的 VB 课,最后的大作业一个游戏就是这样的风格

```vb

If keyascii = 119 Then

Image1.Top = Image1.Top - 200

End If

If keyascii = 115 Then

Image1.Top = Image1.Top + 200

End If

If keyascii = 97 Then

Image1.Left = Image1.Left - 200

End If

If keyascii = 100 Then

Image1.Left = Image1.Left + 200

End If

If keyascii = 32 Then

If Image3(4).Visible = False Then

Call m3

Else

Call m1

WindowsMediaPlayer1.Enabled = False

Image3(i).Visible = False

i = i + 1

If i = 5 Then i = 0

If Abs((Image1.Left + Image1.Width / 2) - (Image2.Left + Image2.Width / 2)) <= Image2.Width / 3 And Abs((Image1.Top + Image1.Height / 2) - (Image2.Top + Image2.Height / 2)) <= (9 / 10) * Image2.Height Then

If Image2.Picture = Image4.Picture Then

p = 1

Else

a = a - 1

Label2.Caption = a

End If

Image2.Picture = Image4.Picture

End If

If Abs((Image1.Left + Image1.Width / 2) - (Image11.Left + Image11.Width / 2)) <= Image11.Width / 3 And Abs((Image1.Top + Image1.Height / 2) - (Image11.Top + Image11.Height / 2)) <= (9 / 10) * Image11.Height Then

If Image11.Picture = Image12.Picture Then

p = 1

Else

a = a - 1

Label2.Caption = a

End If

Image11.Picture = Image12.Picture

Timer1.Enabled = False

End If

If Abs((Image1.Left + Image1.Width / 2) - (Image7.Left + Image7.Width / 2)) <= Image7.Width / 3 And Abs((Image1.Top + Image1.Height / 2) - (Image7.Top + Image7.Height / 2)) <= (9 / 10) * Image7.Height Then

If Image7.Picture = Image13.Picture Then

p = 1

Else

a = a - 1

Label2.Caption = a

End If

Image7.Picture = Image13.Picture

End If

If Abs((Image1.Left + Image1.Width / 2) - (Image8.Left + Image8.Width / 2)) <= Image8.Width / 3 And Abs((Image1.Top + Image1.Height / 2) - (Image8.Top + Image8.Height / 2)) <= (9 / 10) * Image8.Height Then

If Image8.Picture = Image14.Picture Then

p = 1

Else

a = a - 1

Label2.Caption = a

End If

Image8.Picture = Image14.Picture

End If

If Abs((Image1.Left + Image1.Width / 2) - (Image9.Left + Image9.Width / 2)) <= Image9.Width / 3 And Abs((Image1.Top + Image1.Height / 2) - (Image9.Top + Image9.Height / 2)) <= (9 / 10) * Image9.Height Then

If Image9.Picture = Image15.Picture Then

p = 1

Else

a = a - 1

Label2.Caption = a

End If

Image9.Picture = Image15.Picture

Image9.Move 15000

Timer2.Enabled = True

End If

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值