Showing posts with label TIMEPASS. Show all posts
Showing posts with label TIMEPASS. Show all posts

Friday, December 23, 2011

Boggle

This is a type of words puzzle game where players can form as many words as possible from the characters displayed on a nxn square. Words can be formed in many ways, from left to right, from right to left, top to bottom, bottom to top, diagonal, zigzag manner and etc. You can actually play boggle online.
n this programme, I have designed a 5x5 boggle. Each time a player press the shake button, a different set of characters will appear. In order to do this, I use the randomize concept. This programme generates an array of 26 characters and displays them on an array of 24 labels by using  a For...Next loop . The procedure may look simple but it need a lot of thinking before we come out with the idea.

The Code

Dim char(25) As String

Dim I As Integer
Dim J As Integer

Private Sub Command1_Click()
char(0) = "A"
char(1) = "B"
char(2) = "C"
char(3) = "D"
char(4) = "E"
char(5) = "E"
char(6) = "G"
char(7) = "H"
char(8) = "I"
char(9) = "J"
char(10) = "K"
char(11) = "L"
char(12) = "M"
char(13) = "N"
char(14) = "O"
char(15) = "P"
char(16) = "Q"
char(17) = "R"
char(18) = "S"
char(19) = "T"
char(20) = "U"
char(21) = "V"
char(22) = "W"
char(23) = "X"
char(24) = "Y"
char(25) = "Z"

Randomize Timer
For I = 0 To 24
J = Int((Rnd * 26))
Label1(I).Caption = char(J)
Next

End Sub

Saturday, December 17, 2011

Star War

 I have designed this game for educational purpose. This program can demonstrate the principle of projectile, a typical physics problem. At a certain angle and a certain launch velocity, the projectile can reach a certain range. The maximum range is at an angle of 45 degree.
 Part of the code
'To randomly set the initial positions of the objects

left1 = Int(Rnd * 7000) + 1000
left2 = Int(Rnd * 7000) + 1000
left3 = Int(Rnd * 7000) + 1000
top1 = Int(Rnd * 5000) + 100
top2 = Int(Rnd * 5000) + 100
top3 = Int(Rnd * 5000) + 100
Image2.Left = left1
Image3.Left = left2
Image4.Left = left3
Image2.Top = top1
Image3.Top = top2
Image4.Top = top3
w = 0
score = 0
Label7.Caption = Str$(score)
End Sub

Private Sub Image7_Click()
Label5.Visible = False
End Sub
 

Private Sub Timer1_Timer()

MMControl1.Command = "close"

If Image1.Left < 15000 And Image1.Top < 9000 Then

v = Val(Text1.Text)
a = Val(Text2.Text)
t = t + 1
' To use the formula vertical displacement=vsina- (1/2)gt^2 and horizontal displacement=vcosa*t
'So that it follows a parabolic trajectory

y = v * Sin(a * 3.141592654 / 180) * t - 4.9 * (t ^ 2)
x = v * Cos(a * 3.141592654 / 180) * t
Image1.Move Image1.Left + x, Image1.Top - y
If Image4.Visible = True And (Image1.Left < left3 + 240 And Image1.Left > left3 - 240) And (Image1.Top < top3 + 240 And Image1.Top > top3 - 240) Then
i = 2