对于我的AS级别,我需要制作一个小游戏。我想做的是做一个类似于 Cookie Clicker ( http://orteil.dashnet.org/cookieclicker/ ) 的游戏。
我给出的问题是,一旦购买了一件物品(即生产更多松饼),我不知道如何让它随着时间的推移为现有变量(在这种情况下为松饼)增加价值。
这是我的代码的第一块:
Public Class Form1
Dim muffin As Integer
Private Property costgrandma As Integer
Private Property grandma As Integer
Private Sub Makemuffin_Click(sender As Object, e As EventArgs) Handles Button1.Click
muffin += 1
LblMuffinCount.Text = muffin
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
muffin = 0
costgrandma = 20
grandma = 0
End Sub
Private Sub CmdGrandma_Click(sender As Object, e As EventArgs) Handles CmdGrandma.Click
If muffin >= costgrandma Then
grandma += 1
LblGrandmaCount.Text = grandma
muffin = muffin - costgrandma
LblMuffinCount.Text = muffin
costgrandma = costgrandma * 1.05
LblGrandma.Text = costgrandma
Else
MsgBox("Not enough muffins to pay grandma off")
End If
End Sub
我想做的是制作一个潜艇,根据有多少奶奶随着时间的推移添加一些“松饼”。例如,如果您拥有 1 个祖母,它会每秒自动创建另一个松饼。如果有 10 个奶奶,那么每秒会自动做 10 个松饼。