Forum studentów Informatyki Zaocznej na Uniwersytecie Opolskim

Forum studentów Informatyki Zaocznej na Uniwersytecie Opolskim


#1 2008-12-06 16:47:29

wieslawski

Użytkownik

1594022
Zarejestrowany: 2008-10-13
Posty: 59
Punktów :   

pacman

To jest moja darmowa wersja beta

http://www.yousendit.com/download/TTZuY … bHlGa1E9PQ

Ostatnio edytowany przez wieslawski (2008-12-06 17:02:39)

Offline

 

#2 2008-12-06 18:54:48

ciemak666

Użytkownik

5089189
Zarejestrowany: 2008-10-12
Posty: 102
Punktów :   

Re: pacman

jeśli możesz to daj kod źródłowy

Offline

 

#3 2008-12-06 21:05:25

wieslawski

Użytkownik

1594022
Zarejestrowany: 2008-10-13
Posty: 59
Punktów :   

Re: pacman

Kod:

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

 

#4 2008-12-07 06:55:55

Banan

Administrator

2387785
Call me!
Skąd: K-Koźle
Zarejestrowany: 2008-10-13
Posty: 131
Punktów :   

Re: pacman

haha
fajne;p
coprawda jeszcze nie dziala do konca ale juz bardzo duzo zrobione:P
czasem buguje sie gra i mnozy sie postac


http://img194.imageshack.us/img194/2751/newlogog.png
Zapraszam na forum www.lockerz-forum.eu

Offline

 

#5 2008-12-07 19:01:43

ciemak666

Użytkownik

5089189
Zarejestrowany: 2008-10-12
Posty: 102
Punktów :   

Re: pacman

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

 

#6 2008-12-10 20:49:53

Lea501

Nowy użytkownik

Zarejestrowany: 2008-12-10
Posty: 2
Punktów :   

Re: pacman

Witam !
Ciekawe czy chociaż jedna linijka tego kodu będzie dla mnie czytelna,ech...

Offline

 

#7 2008-12-19 14:07:01

wieslawski

Użytkownik

1594022
Zarejestrowany: 2008-10-13
Posty: 59
Punktów :   

Re: pacman

Offline

 

#8 2009-01-10 18:42:35

Andrzej

Użytkownik

Zarejestrowany: 2008-10-13
Posty: 50
Punktów :   

Re: pacman

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

 

#9 2009-01-10 20:50:07

ciemak666

Użytkownik

5089189
Zarejestrowany: 2008-10-12
Posty: 102
Punktów :   

Re: pacman

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

 

#10 2009-01-12 09:27:58

anubiss

Użytkownik

6888343
Skąd: .
Zarejestrowany: 2008-10-11
Posty: 65
Punktów :   

Re: pacman

Wydaje mi się, że ten program to raczej sprawa ambitnego podejścia, a nie oceny.


Pogotowie Komputerowe REAKTOR - Częstochowa
www.pogotowie-komputerowe.info
www.vrsolutions.com.pl

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora
www.error-skateboards.pun.pl www.fifamanager09.pun.pl www.elffortress.pun.pl www.shitpower.pun.pl www.worldofnaruto-ots.pun.pl