Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Math
- Imports System.Drawing.Drawing2D
- Imports System.IO
- Imports System.Uri
- Imports System.Threading
- Imports System.String
- Public Class Form1
- Private lvln As Decimal
- Private leveln As String
- 'Private lvl0 As Bitmap = New Bitmap("Prolougelevel.bmp")
- 'Private lvl1a As Bitmap
- 'Private lvl1b As Bitmap
- Private level As Bitmap
- 'repeat for number of levels needed-ignore
- Private canvas As Graphics
- Private sccanvb As Graphics
- Private scpic As Bitmap
- Private sccanvp As Graphics
- Private sccanve As Graphics
- Private sccanva As Graphics
- Private lvlx As Integer = 0
- Private lvly As Integer = 0
- Private lvlw As Integer
- Private lvlht As Integer
- Private terx As Integer = 5
- Private tery As Integer = 5
- Private terw As Integer
- Private terht As Integer
- Private fw As Integer
- Private fht As Integer
- Private picx As Integer
- Private picy As Integer
- Private teraunce As Bitmap = New Bitmap("Teraunce0.bmp")
- Private terrect As Rectangle
- Private ters As Integer = 0
- Private win As Boolean = False
- Private quit As Boolean = False
- Private terj As Integer = 0
- Private terjump1 As Boolean = False
- Private terjump2 As Boolean = False
- Private terjump3 As Boolean
- Private terright As Boolean = False
- Private fired As Boolean = False
- Private floor1 As Rectangle
- Private floor2 As Rectangle
- Private plat1r As Rectangle
- Private plat2r As Rectangle
- Private plat3r As Rectangle
- Private wall1rr As Rectangle
- Private wllrrx1 As Integer
- Private wllrry1 As Integer
- Private wllrrw1 As Integer
- Private wllrrh1 As Integer
- Private wall2rr As Rectangle
- Private wllrrx2 As Integer
- Private wllrry2 As Integer
- Private wllrrw2 As Integer
- Private wllrrh2 As Integer
- Private wall3rr As Rectangle
- Private wllrrx3 As Integer
- Private wllrry3 As Integer
- Private wllrrw3 As Integer
- Private wllrrh3 As Integer
- Private wall1rl As Rectangle
- Private wllrlx1 As Integer
- Private wllrly1 As Integer
- Private wllrlw1 As Integer
- Private wllrlh1 As Integer
- Private wall2rl As Rectangle
- Private wllrlx2 As Integer
- Private wllrly2 As Integer
- Private wllrlw2 As Integer
- Private wllrlh2 As Integer
- Private wall3rl As Rectangle
- Private wllrlx3 As Integer
- Private wllrly3 As Integer
- Private wllrlw3 As Integer
- Private wllrlh3 As Integer
- Private enemy1r As Rectangle
- Private enemy1 As Bitmap
- Private enemy2r As Rectangle
- Private enemy2 As Bitmap
- Private enemy3r As Rectangle
- Private enemy3 As Bitmap
- Private goblin As Bitmap 'enemy bitmaps once found
- Private troll As Bitmap
- Private exit1r As Rectangle
- Private exit2r As Rectangle
- Private exit3r As Rectangle
- Private ceilingr As Rectangle
- Private terbit As String
- Private run As Boolean = False
- Private lvlmove As Matrix
- Private termove As Matrix
- Private enemymove As Matrix
- Private terup As Boolean
- Private hp As Integer = 8
- Private maxhp As Integer = 8
- Private mp As Integer = 3
- Private maxmp As Integer = 3
- Private xp As Integer = 0
- Private lvlxp As Integer = 100
- Private TerLvl As Integer = 1
- Private sjump As Decimal
- Private Sjump2 As Decimal
- Private sjump3 As Decimal
- Private arrows As Integer = 20
- Private arrowrect As Rectangle
- Private bitArrow As Bitmap = New Bitmap("arrowr.bmp")
- Private tempstring As String
- Private temprect As Rectangle
- Private rightmove As Matrix
- Private leftmove As Matrix
- Private remover As Rectangle = New Rectangle(-9999, -9999, 1, 1)
- Private gravity As Matrix = New Matrix(1, 0, 0, 1, 0, -5)
- Private antigrav As Matrix = New Matrix(1, 0, 0, 1, 0, 6)
- Private mat_jump As Matrix
- Private dy As Decimal
- Private dx As Decimal
- Private dly As Integer = 0
- Private dlx As Integer = 0
- Private dex As Integer = 0
- Private dey As Integer = 0
- Private dax As Integer = 0
- Private day As Integer = 0
- Private arx As Integer
- Private ary As Integer
- 'repeat as necessary
- Private Sub startbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startbtn.Click
- 'variables set...
- scpic = New Bitmap(PicAnim.Width, PicAnim.Height)
- terrect = New Rectangle(terx, tery, teraunce.Width, teraunce.Height)
- sccanvb = Graphics.FromImage(scpic)
- sccanvp = Graphics.FromImage(scpic)
- sccanve = Graphics.FromImage(scpic)
- sccanva = Graphics.FromImage(scpic)
- floor1 = remover
- floor2 = remover
- bitArrow.MakeTransparent(Color.Blue)
- fw = PicAnim.Width
- fht = PicAnim.Height
- startbtn.Enabled = False
- closebtn.Enabled = False
- levelselect.Enabled = False
- If levelselect.Text = " ." Then
- levelselect.Text = "000."
- End If
- lvln = levelselect.Text
- canvas = PicAnim.CreateGraphics
- quit = False
- terht = teraunce.Height
- terw = teraunce.Width
- Do
- If terjump1 = False Then
- tersprite() 'cycles through idle animation sprites
- Else
- If terup = True Then 'jump area
- terjumpup()
- ElseIf terright = False Then
- terjumpleft()
- Else
- terjumpright()
- End If
- End If
- HPcurLbl.Text = Convert.ToString(hp)
- HPmaxLbl.Text = maxhp
- MPcurLbl.Text = mp
- MPmaxLbl.Text = maxmp
- LvlCurLbl.Text = TerLvl
- XPcurLbl.Text = xp
- NextLvlLbl.Text = lvlxp
- passwordlevel.Text = lvln
- If run = False Then
- terlevel()
- End If
- 'YTF is it skipping levels?---Fixed
- Application.DoEvents()
- canvas.DrawImage(scpic, 0, 0)
- 'sccanvb.MultiplyTransform(gravity) 'not transforming for some reason. IDK why though. major bug that needs fixing.
- sccanvb.DrawImage(level, lvlx + dlx, lvly + dly)
- Thread.Sleep(1)
- sccanvp.DrawImage(teraunce, terrect)
- leveldo()
- If hp <= 0 Then
- lvln = 666
- lvlx = 0
- lvly = 0
- End If
- dly = dly - 5
- If run = True Then
- If terrect.IntersectsWith(enemy1r) = True Then
- hp = hp - 1
- ElseIf terrect.IntersectsWith(enemy2r) = True Then
- hp = hp - 1
- ElseIf terrect.IntersectsWith(enemy3r) = True Then
- hp = hp - 1
- ElseIf terrect.IntersectsWith(exit1r) = True Then
- fexit1()
- ElseIf terrect.IntersectsWith(exit2r) = True Then
- fexit2()
- ElseIf terrect.IntersectsWith(exit3r) = True Then
- fexit3()
- ElseIf terrect.IntersectsWith(floor1) = True Then
- 'sccanvb.MultiplyTransform(antigrav)
- dly = dly + 6
- ElseIf terrect.IntersectsWith(floor2) = True Then
- 'sccanvb.MultiplyTransform(antigrav)
- dly = dly + 6
- End If
- End If
- If fired = True Then
- If terright = True Then
- dax = dax + 10
- Else
- dax = dax - 10
- End If
- arx = terx + dax - dlx
- ary = tery + day - dly
- arrowrect = New Rectangle(arx, ary, bitArrow.Width, bitArrow.Height)
- sccanva.DrawImage(bitArrow, arrowrect)
- If temprect.Intersect(arrowrect, enemy1r) <> Nothing Then
- enemy1r = remover
- arrowrect = remover
- fired = False
- sccanva.DrawImage(bitArrow, arrowrect)
- sccanve.DrawImage(enemy1, enemy1r)
- xp = xp + 15
- ElseIf temprect.Intersect(arrowrect, enemy2r) <> Nothing Then
- enemy2r = remover
- arrowrect = remover
- fired = False
- sccanva.DrawImage(bitArrow, arrowrect)
- sccanve.DrawImage(enemy2, enemy2r)
- xp = xp + 15
- ElseIf temprect.Intersect(arrowrect, enemy3r) <> Nothing Then
- enemy3r = remover
- arrowrect = remover
- fired = False
- sccanva.DrawImage(bitArrow, arrowrect)
- sccanve.DrawImage(enemy3, enemy3r)
- xp = xp + 15
- ElseIf ary < 0 Then
- fired = False
- ElseIf ary > level.Height Then
- fired = False
- ElseIf arx < 0 Then
- fired = False
- ElseIf arx > level.Width Then
- fired = False
- End If
- End If
- 'lvly = lvly - 5
- Thread.Sleep(100)
- Loop Until quit = True
- 'Close()
- End Sub
- Function fexit1()
- If lvln = 0 Then
- lvln = 0.1
- terx = 200
- End If
- End Function
- Function fexit2()
- End Function
- Function fexit3()
- End Function
- Function rectfix()
- wall1rl = New Rectangle(wllrlx1 + lvlx, wllrly1 + lvly, wllrlw1 + lvlx, wllrlh1 + lvly)
- wall2rl = New Rectangle(wllrlx2 + lvlx, wllrly2 + lvly, wllrlw2 + lvlx, wllrlh2 + lvly)
- wall3rl = New Rectangle(wllrlx3 + lvlx, wllrly3 + lvly, wllrlw3 + lvlx, wllrlh3 + lvly)
- wall1rr = New Rectangle(wllrrx1 + lvlx, wllrry1 + lvly, wllrrw1 + lvlx, wllrrh1 + lvly)
- wall2rr = New Rectangle(wllrrx2 + lvlx, wllrry2 + lvly, wllrrw2 + lvlx, wllrrh2 + lvly)
- wall3rr = New Rectangle(wllrrx3 + lvlx, wllrry3 + lvly, wllrrw3 + lvlx, wllrrh3 + lvly)
- End Function
- Function tersprite()
- 'Do
- If ters <= 16 Then
- terbit = Convert.ToString(ters)
- teraunce = New Bitmap("Teraunce" + terbit + ".bmp") 'should return Teraunce0.bmp to teraunce16.bmp
- ters = ters + 1
- teraunce.MakeTransparent(Color.Blue)
- Else
- ters = 0
- End If
- 'Loop While quit = False <---Unneeded, couldn't be escaped.
- 'sample function-finished
- 'TODO://Draw Idle/Walk/jump/glide animation for Teraunce-incomplete; placeholder added.
- End Function
- Function terjumpup()
- If terjump1 = False Then
- sjump = 0
- sjump2 = 0
- sjump3 = 0
- End If
- If terjump1 = True Then
- terjump1 = False
- terbit = Convert.ToString(sjump)
- sjump = sjump + 0.1
- teraunce = New Bitmap("teraunce" + terbit + "u1.bmp")
- dly = ((16 * (sjump ^ 2)) - (50 * sjump)) * -1
- mat_jump = New Matrix(0, 1, 1, 0, 0, -dy)
- 'sccanvb.MultiplyTransform(mat_jump)
- ElseIf terjump2 = True Then
- terjump1 = False
- terbit = Convert.ToString(Sjump2)
- Sjump2 = Sjump2 + 0.1
- teraunce = New Bitmap("teraunce" + terbit + "u2.bmp")
- dly = ((16 * (Sjump2 ^ 2)) - (50 * Sjump2)) * -1
- mat_jump = New Matrix(0, 1, 1, 0, 0, -dy)
- 'sccanvb.MultiplyTransform(mat_jump)
- Else
- If terright = True Then
- terglideright()
- Else
- terglideleft()
- End If
- End If
- End Function
- Function terjumpright()
- terjump1 = False
- End Function
- Function terjumpleft()
- terjump1 = False
- End Function
- Function terglideright()
- End Function
- Function terglideleft()
- End Function
- Function terlevel()
- leveln = Convert.ToString(lvln)
- level = New Bitmap("level" + leveln + ".bmp")
- End Function
- Function leveldo()
- If lvln = 0.0 Then
- 'lvly = lvly
- If run = False Then
- sccanvb.DrawImage(level, lvlx, lvly)
- run = True
- ElseIf run = True Then
- Thread.Sleep(1)
- End If
- ElseIf lvln = 0.1 Then
- If run = False Then
- sccanvb.DrawImage(level, lvlx, lvly)
- run = True
- ElseIf run = True Then
- End If
- Else
- If run = False Then
- sccanvb.DrawImage(level, lvlx, lvly)
- run = True
- Else
- End If
- End If
- End Function
- Private Sub closebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closebtn.Click
- If quit = False Then
- quit = True
- startbtn.Enabled = True
- levelselect.Enabled = True
- run = False
- Else
- Close()
- End If
- End Sub
- Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
- If e.KeyCode = Keys.NumPad8 Then
- terup = True
- If terjump1 = False Then
- terjump1 = True
- terjumpup()
- ElseIf terjump2 = False Then
- terjump2 = True
- terjumpup()
- Else
- If terright = True Then
- terglideright()
- Else
- terglideleft()
- End If
- End If
- ElseIf e.KeyCode = Keys.NumPad9 Then
- terright = True
- If terjump1 = False Then
- terjump1 = True
- terjumpright()
- ElseIf terjump2 = False Then
- terjump2 = True
- terjumpright()
- Else
- If terright = True Then
- terglideright()
- Else
- terglideleft()
- End If
- End If
- ElseIf e.KeyCode = Keys.NumPad7 Then
- terright = False
- If terjump1 = False Then
- terjump1 = True
- terjumpleft()
- ElseIf terjump2 = False Then
- terjump2 = True
- terjumpleft()
- Else
- If terright = True Then
- terglideright()
- Else
- terglideleft()
- End If
- End If
- ElseIf e.KeyCode = Keys.End Then
- closebtn_Click(sender, e)
- ElseIf e.KeyCode = Keys.NumPad4 Then
- terup = False
- dlx = dlx + 3
- terright = False
- ElseIf e.KeyCode = Keys.NumPad6 Then
- terup = False
- terright = True
- dlx = dlx - 3
- ElseIf e.KeyCode = Keys.ControlKey Then
- If arrows > 0 Then
- If fired = False Then
- dax = 0
- day = 0
- arrowrect = New Rectangle(terx, tery, bitArrow.Width, bitArrow.Height)
- If terright = True Then
- bitArrow = New Bitmap("arrowr.bmp")
- Else
- bitArrow = New Bitmap("arrowl.bmp")
- End If
- bitArrow.MakeTransparent(Color.Blue)
- sccanva.DrawImage(bitArrow, arrowrect)
- dax = 0
- day = 0
- fired = True
- arrows = arrows - 1
- NumArrowLbl.Text = arrows
- Else
- tempstring = New String("Wait!")
- NumArrowLbl.Text = tempstring
- End If
- Else
- tempstring = New String("Empty")
- NumArrowLbl.Text = tempstring
- End If
- End If
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- Private Sub HPcurLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HPcurLbl.Click
- End Sub
- Private Sub HPmaxLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HPmaxLbl.Click
- End Sub
- Private Sub LvlCurLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LvlCurLbl.Click
- End Sub
- Private Sub MPcurLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPcurLbl.Click
- End Sub
- Private Sub MPmaxLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MPmaxLbl.Click
- End Sub
- Private Sub XPcurLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles XPcurLbl.Click
- End Sub
- Private Sub NextLvlLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NextLvlLbl.Click
- End Sub
- Private Sub NumArrowLbl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumArrowLbl.Click
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement