PDA

View Full Version : مشکل در مورد بازی هواپیما



saeed hg
چهارشنبه 28 اسفند 1392, 11:58 صبح
سلام دوستان .

در ویبی دات نت در حال تاتی تاتی کردن هستم و سورس این بازی برام جالب بود ،
یه سری سوالاتی دارم که اگه میشه راهنماییم بفرمایید.


من برای اینکه تمام هواپیماها رو نمایش بدم در mdlMain تغییر زیر رو دادم
Friend myLevel As Integer = 5 .


من در فرم frmmain تغییر زیر رو دادم :



' This part adds planes to your game
Private Sub addPlanes(ByVal myCount As Integer)
Static myPlanesNo As Integer

For i As Integer = 1 To myCount
myPlanes = New frmPlanes
myPlanesNo = myPlanesNo + 1
myPlanes.Tag = "F" & myPlanesNo ' for control a special plane in a collectin
myPlanesCollection.Add(myPlanes, "F" & myPlanesNo)
myPlanes.Show()
myRemainEnemies -= 1
If myPlanesCollection.Count >= 15 Then Exit For ' you have only 5 active airplane on screen. ( more planes need faster CPU )
Next
myEnemies = myRemainEnemies + myPlanesCollection.Count
'myBackground.RefreshData()
End Sub


'timer for moving airplanes on screen, when planes are out of screen, they will placed in new location at top of screen
Private Sub tmrPlane_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPlane.Tick

For Each myPlane As frmPlanes In myPlanesCollection
If (myPlane.Location.X > myMaxWidth * 1.2 OrElse myPlane.Location.Y > myMaxHeight) Then
'airplane is out of screen at right
myPlane.planeSize = Int(Rnd(1) * 25) + 5 ' random size at new location
myPlane.Size = New Size(1, 1) ' when I want to change location to new area at left, size of plane is too big and make a bad effect.
Application.DoEvents()
myPlane.Location = New Point(Int(Rnd(1) * myMaxWidth / 4) - 100, -50) ' new location at left
ElseIf myPlane.Location.X < -myMaxWidth * 0.2 OrElse myPlane.Location.Y > myMaxHeight Then
'airplane is out of screen at left
myPlane.planeSize = Int(Rnd(1) * 25) + 5 ' random size at new location
myPlane.Location = New Point(myMaxWidth + Int(Rnd(1) * myMaxWidth / 4), -50) ' new location at right
End If

myPlane.planeSize += (mySpeed / 800)
If myPlane.planeSize > 200 Then myPlane.planeSize = 200
myPlane.picPlanes.Size = New Size(myPlane.planeSize, myPlane.planeSize * 0.5)
myPlane.Size = myPlane.picPlanes.Size
myPlane.Location = New Point(myPlane.Location.X, myPlane.Location.Y + 5)
Next
End Sub






اما وقتی عدد 15 میزارم بعد از تقریبا 30 ثانیه، بعضی از هواپیماها زیر صفحه گیر میکنند و ارور زیر رومیده!!!


117144



وقتی این گروه از هواپیماها رسیدن به انتهای صفحه نمایش، گروه بعدی میاد، من می خوام مثلا وقتی این گروه از هواپیماها رسیدن به وسط صفحه گروه بعدی بیاد!
جانمایی هواپیماها خوب نیست و بیشتر مواقع تصاویر دو هواپیما میوفته رو هم! و یا از چپ و راست تصویر میزنه بیرون!




در فرم frmAirPlanesGallery چرا نوع عکسها رو زده .Image ؟


مثال :



Me.Flight1Right.Image = CType(resources.GetObject("Flight1Right.Image"), System.Drawing.Image)




یا در فرمfrmPlanes :





picPlanes.Image = Choose(planeType, myPlanesGallery.Flight3Left.Image, myPlanesGallery.Flight3Right.Image, myPlanesGallery.Flight1Left.Image, myPlanesGallery.Flight1Right.Image, myPlanesGallery.Flight4Left.Image, myPlanesGallery.Flight4Right.Image, myPlanesGallery.Flight2Left.Image, myPlanesGallery.Flight2Right.Image, myPlanesGallery.Flight5Left.Image, myPlanesGallery.Flight5Right.Image) 'before showing a plane, it must choose airplane picture from gallery .



مگه نوع عکسها نباید .png و ترنسپرنت باشه؟