Hallo,
ich hab vorhin mal das hier hingekritzelt:
Spoiler anzeigen
Ich weiss, mieser Codestil, bla bla....
Die Verwendung sollte klar sein.
Nur falls jemand das braucht.
Grüße
ich hab vorhin mal das hier hingekritzelt:
VB.NET-Quellcode
- ''' <summary>
- ''' This is the main type for your game
- ''' </summary>
- Public Class PauseMenu
- Inherits Microsoft.Xna.Framework.DrawableGameComponent
- Enum State
- Rein
- Raus
- Nichts
- End Enum
- Private WithEvents graphics As GraphicsDeviceManager
- Private WithEvents spriteBatch As SpriteBatch
- Private bgtexture As Texture2D
- Private Size As Vector2
- Private Point As Vector2
- Private Drawen As Boolean = True
- Private statemod As State = State.Nichts
- Public Sub New(ByVal game As Game, ByVal spriteBatch As SpriteBatch)
- MyBase.New(game)
- Me.spriteBatch = spriteBatch
- Size = New Vector2(game.Window.ClientBounds.Width, game.Window.ClientBounds.Height)
- Point = New Vector2(0 - game.Window.ClientBounds.Width, 0)
- End Sub
- ''' <summary>
- ''' Allows the game to perform any initialization it needs to before starting to run.
- ''' This is where it can query for any required services and load any non-graphic
- ''' related content. Calling MyBase.Initialize will enumerate through any components
- ''' and initialize them as well.
- ''' </summary>
- Public Overrides Sub Initialize()
- ' TODO: Add your initialization logic here
- MyBase.Initialize()
- End Sub
- ''' <summary>
- ''' LoadContent will be called once per game and is the place to load
- ''' all of your content.
- ''' </summary>
- Protected Overrides Sub LoadContent()
- ' Create a new SpriteBatch, which can be used to draw textures.
- 'spriteBatch = New SpriteBatch(GraphicsDevice)
- bgtexture = Game.Content.Load(Of Texture2D)("bgtexture")
- ' TODO: use Me.Content to load your game content here
- MyBase.LoadContent()
- End Sub
- ''' <summary>
- ''' UnloadContent will be called once per game and is the place to unload
- ''' all content.
- ''' </summary>
- Protected Overrides Sub UnloadContent()
- ' TODO: Unload any non ContentManager content here
- End Sub
- ''' <summary>
- ''' Allows the game to run logic such as updating the world,
- ''' checking for collisions, gathering input, and playing audio.
- ''' </summary>
- ''' <param name="gameTime">Provides a snapshot of timing values.</param>
- Public Overrides Sub Update(ByVal gameTime As GameTime)
- Dim val As Integer = +5
- If statemod = State.Raus Then
- val = +5
- ElseIf statemod = State.Rein Then
- val = -5
- End If
- If statemod = State.Raus Then
- If Point.X + Game.Window.ClientBounds.Width = Game.Window.ClientBounds.Width / 2 / 2 Then
- Else
- Point.X += val
- End If
- End If
- If statemod = State.Rein Then
- If Point.X + Game.Window.ClientBounds.Width = 0 Then
- 'statemod = State.Raus
- Else
- Point.X += val
- End If
- End If
- MyBase.Update(gameTime)
- End Sub
- ''' <summary>
- ''' This is called when the game should draw itself.
- ''' </summary>
- ''' <param name="gameTime">Provides a snapshot of timing values.</param>
- Public Overrides Sub Draw(ByVal gameTime As GameTime)
- 'GraphicsDevice.Clear(Color.CornflowerBlue)
- spriteBatch.Begin()
- 'spriteBatch.End()
- spriteBatch.Draw(bgtexture, New Rectangle(Point.X, Point.Y, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height), New Color(0, 0, 210, 200))
- spriteBatch.End()
- ' TODO: Add your drawing code here
- MyBase.Draw(gameTime)
- End Sub
- Sub Reinfahren(ByVal steps As Integer)
- statemod = State.Rein
- End Sub
- Sub Rausfahren(ByVal steps As Integer)
- statemod = State.Raus
- End Sub
- End Class
Ich weiss, mieser Codestil, bla bla....
Die Verwendung sollte klar sein.
Nur falls jemand das braucht.
Grüße