Forum studentów Informatyki Zaocznej na Uniwersytecie Opolskim
Użytkownik
To jest moja darmowa wersja beta
http://www.yousendit.com/download/TTZuY … bHlGa1E9PQ
Ostatnio edytowany przez wieslawski (2008-12-06 17:02:39)
Offline
Offline
Użytkownik
Public Class Form1 Dim x, y, n As Integer Dim w1x, w1y, w1kier As Integer Dim plansza As Integer(,) Dim pktdozebrania As Integer Dim liczba_przec = 2 Dim zebrane As Integer = 0 Dim tabprzec As Integer(,) Dim zycia As Integer = 3 Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Randomize() tabprzec = New Integer(1, 2) {{3, 5, 2}, {0, 7, 2}} plansza = New Integer(9, 9) {{0, 0, 101, 0, 0, 2, 0, 22, 0, 0}, {0, 0, 2, 0, 0, 2, 0, 2, 0, 0}, {0, 0, 2, 0, 0, 2, 0, 2, 0, 0}, {2, 2, 2, 2, 2, 12, 2, 2, 2, 2}, {0, 0, 2, 0, 0, 2, 0, 2, 0, 0}, {0, 0, 2, 2, 2, 2, 2, 2, 2, 2}, {0, 0, 2, 0, 0, 2, 0, 2, 0, 0}, {0, 0, 2, 0, 0, 2, 0, 2, 0, 0}, {0, 0, 2, 0, 0, 2, 0, 2, 0, 0}, {0, 0, 2, 0, 0, 2, 0, 2, 0, 0}} pktdozebrania = 40 Dim i, j As Integer For i = 0 To 9 For j = 0 To 9 If plansza(i, j) = 101 Then x = i y = j End If Next Next Timer1.Enabled = True End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim rys As Graphics = CreateGraphics() Dim i, j As Integer For i = 0 To 9 For j = 0 To 9 If plansza(i, j) = 2 Then rys.FillRectangle(Brushes.Gray, 20 + 21 * i, 20 + 21 * j, 20, 20) rys.FillEllipse(Brushes.Yellow, 25 + 21 * i, 25 + 21 * j, 10, 10) End If If plansza(i, j) = 0 Then rys.FillRectangle(Brushes.Blue, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 1 Then rys.FillRectangle(Brushes.Gray, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 100 Then rys.FillRectangle(Brushes.White, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 12 Then rys.FillRectangle(Brushes.Red, 20 + 21 * i, 20 + 21 * j, 20, 20) rys.FillEllipse(Brushes.Yellow, 25 + 21 * i, 25 + 21 * j, 10, 10) End If If plansza(i, j) = 22 Then rys.FillRectangle(Brushes.Violet, 20 + 21 * i, 20 + 21 * j, 20, 20) rys.FillEllipse(Brushes.Yellow, 25 + 21 * i, 25 + 21 * j, 10, 10) End If If plansza(i, j) = 11 Then rys.FillRectangle(Brushes.Red, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 21 Then rys.FillRectangle(Brushes.Violet, 20 + 21 * i, 20 + 21 * j, 20, 20) Next Next Label1.Text = CStr(x) + ", " + CStr(y) End Sub Private Sub rys() Dim rys As Graphics = CreateGraphics() Dim i, j As Integer For i = 0 To 9 For j = 0 To 9 If plansza(i, j) = 1 Then rys.FillRectangle(Brushes.Gray, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 0 Then rys.FillRectangle(Brushes.Blue, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 2 Then rys.FillRectangle(Brushes.Black, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 100 Then rys.FillRectangle(Brushes.White, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 11 Then rys.FillRectangle(Brushes.Red, 20 + 21 * i, 20 + 21 * j, 20, 20) rys.FillEllipse(Brushes.Gray, 25 + 21 * i, 25 + 21 * j, 10, 10) End If If plansza(i, j) = 21 Then rys.FillRectangle(Brushes.Yellow, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 10 Then rys.FillRectangle(Brushes.Red, 20 + 21 * i, 20 + 21 * j, 20, 20) If plansza(i, j) = 20 Then rys.FillRectangle(Brushes.Yellow, 20 + 21 * i, 20 + 21 * j, 20, 20) Next Next Label1.Text = CStr(x) + ", " + CStr(y) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If y - 1 = -1 Then If Not plansza(x, 9) = 0 Then plansza(x, y) = 1 y = 9 plansza(x, y) += 100 End If Else If Not plansza(x, y - 1) = 0 Then plansza(x, y) = 1 y -= 1 plansza(x, y) += 100 End If End If czy_zdarzenie(x, y) End Sub Sub czy_zdarzenie(ByRef x As Integer, ByRef y As Integer) Label4.Text = CStr(plansza(x, y)) If plansza(x, y) > 100 Then If plansza(x, y) = 102 Then zebrane += 1 plansza(x, y) = 101 ElseIf plansza(x, y) > 110 Then Label3.Text = " ble ble :(" 'strata_zycia() ElseIf plansza(x, y) = 103 Then 'extra() End If End If Label5.Text = zebrane If zebrane = pktdozebrania Then Label5.Text = "wygrana!!!" Refresh() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If x + 1 = 10 Then If Not plansza(0, y) = 0 Then plansza(x, y) = 1 x = 0 plansza(x, y) += 100 End If Else If Not plansza(x + 1, y) = 0 Then plansza(x, y) = 1 x += 1 plansza(x, y) += 100 End If End If czy_zdarzenie(x, y) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If y + 1 = 10 Then If Not plansza(x, 0) = 0 Then plansza(x, y) = 1 y = 0 plansza(x, y) += 100 End If Else If Not plansza(x, y + 1) = 0 Then plansza(x, y) = 1 y += 1 plansza(x, y) += 100 End If End If czy_zdarzenie(x, y) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If x - 1 = -1 Then If Not plansza(9, y) = 0 Then plansza(x, y) = 1 x = 9 plansza(x, y) = +100 End If Else If Not plansza(x - 1, y) = 0 Then plansza(x, y) = 1 x -= 1 plansza(x, y) += 100 End If End If czy_zdarzenie(x, y) End Sub Private Sub ruch_przec(ByRef wx As Integer, ByRef wy As Integer, ByRef kier As Integer) Label4.Text = CStr(tabprzec(0, 0)) + ", " + CStr(tabprzec(0, 1)) For i As Integer = 0 To liczba_przec - 1 wx = tabprzec(i, 0) wy = tabprzec(i, 1) kier = tabprzec(i, 2) Dim zm As Integer = 1 While zm = 1 If kier = 1 Then If wx + 1 = 10 Then If Not (plansza(0, wy) = 0 Or (10 < plansza(0, wy) And plansza(0, wy) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wx = 0 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If Else If Not (plansza(wx + 1, wy) = 0 Or (10 < plansza(wx + 1, wy) And plansza(wx + 1, wy) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wx += 1 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If End If ElseIf kier = 2 Then If wy - 1 = -1 Then If Not (plansza(wx, 9) = 0 Or (10 < plansza(wx, 9) And plansza(wx, 9) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wy = 9 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If Else If Not (plansza(wx, wy - 1) = 0 Or (10 < plansza(wx, wy - 1) And plansza(wx, wy - 1) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wy -= 1 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If End If ElseIf kier = 3 Then If wx - 1 = -1 Then If Not (plansza(9, wy) = 0 Or (10 < plansza(9, wy) And plansza(9, wy) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wx = 9 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If Else If Not (plansza(wx - 1, wy) = 0 Or (10 < plansza(wx - 1, wy) And plansza(wx - 1, wy) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wx -= 1 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If End If ElseIf kier = 4 Then If wy + 1 = 10 Then If Not (plansza(wx, 0) = 0 Or (10 < plansza(wx, 0) And plansza(wx, 0) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wy = 0 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If Else If Not (plansza(wx, wy + 1) = 0 Or (10 < plansza(wx, wy + 1) And plansza(wx, wy + 1) < 100)) Then plansza(wx, wy) -= (i + 1) * 10 wy += 1 plansza(wx, wy) += (i + 1) * 10 zm = 0 End If End If End If If zm = 1 Or Rnd() > 0.8 Then If kier = 4 Then kier = 1 Else : kier += 1 End If End If End While tabprzec(i, 0) = wx tabprzec(i, 1) = wy tabprzec(i, 2) = kier Next Refresh() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label3.Text = CStr(n) n += 1 ruch_przec(w1x, w1y, w1kier) End Sub End Class
Tylko nie sprzedawać tego, bo to są moje miliony zielonych! ;p
Offline
haha
fajne;p
coprawda jeszcze nie dziala do konca ale juz bardzo duzo zrobione:P
czasem buguje sie gra i mnozy sie postac
Offline
wieslawski napisał:
Tylko nie sprzedawać tego, bo to są moje miliony zielonych! ;p
hehe spoko to moze ty bedziesz pisac .. ja sprzedawać i razem zarobimy miliony
Offline
Użytkownik
Nowa wersja beta pacmana!
http://www.yousendit.com/download/TTZuT … bUlLSkE9PQ
Offline
procedura poruszania za pomocą strzałek na klawiaturze:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Right Then
x += 1
Me.Invalidate()
ElseIf e.KeyCode = Keys.Left Then
x += -1
Me.Invalidate()
ElseIf e.KeyCode = Keys.Down Then
y += 1
Me.Invalidate()
ElseIf e.KeyCode = Keys.Up Then
y += -1
Me.Invalidate()
End If
End Sub
a tutaj jest pacman:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
pacman.FillRectangle(Brushes.Aqua, x * isize, y * isize, 40, 40)
End Sub
Ostatnio edytowany przez Andrzej (2009-01-10 18:48:18)
Offline
no dobra . ale teraz czy opłaca sie pisac ten program na 5 ?
bo niby napisac sie da - to tylko kwestia czasu . Ale czy to cos mi da ze bede miał 5 czy te powiedzmy 4
na 1 semestr ?
chyba lepiej sie pouczyc z logiki / maty
chyba ze ktos pisze dla przyjemności - to to juz całkiem inna sprawa
Offline
Wydaje mi się, że ten program to raczej sprawa ambitnego podejścia, a nie oceny.
Offline