Click here to Skip to main content
15,912,932 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: I don't like java. Pin
Rick York14-Sep-19 6:02
mveRick York14-Sep-19 6:02 
GeneralRe: I don't like java. Pin
honey the codewitch14-Sep-19 6:03
mvahoney the codewitch14-Sep-19 6:03 
GeneralRe: I don't like java. Pin
Brisingr Aerowing14-Sep-19 14:29
professionalBrisingr Aerowing14-Sep-19 14:29 
GeneralRe: I don't like java. Pin
honey the codewitch14-Sep-19 14:30
mvahoney the codewitch14-Sep-19 14:30 
GeneralRe: I don't like java. Pin
Munchies_Matt14-Sep-19 22:49
Munchies_Matt14-Sep-19 22:49 
GeneralRe: I don't like java. Pin
honey the codewitch15-Sep-19 3:33
mvahoney the codewitch15-Sep-19 3:33 
GeneralRe: I don't like java. Pin
MSBassSinger16-Sep-19 3:01
professionalMSBassSinger16-Sep-19 3:01 
GeneralThis is gold (one of my first programming projects) Pin
Sander Rossel14-Sep-19 2:50
professionalSander Rossel14-Sep-19 2:50 
Inspired by witch the codehoney asking about our ugliest code I looked up some of my earliest code.
I was just getting started and wanted to experiment a bit with inheritance.
So I decided to make a (turn based) Final Fantasy like battle game Laugh | :laugh:
It's VB so you're warned... (awesome pictures at the bottom)

Somehow I thought BaseMonster was a good idea (especially notice how I check if the type of Me (this) is not of a specific derived type).
The BackgroundWorker is also pretty neat!
VB
Namespace BaseCharacters

   Public MustInherit Class BaseMonster
      Inherits BaseDefence

      Private m_Name As String
      Private m_Level As Integer
      Private m_HP As Integer
      Private m_CurrentHP As Integer
      Private m_MP As Integer
      Private m_CurrentMP As Integer
      Private m_Strength As Integer
      Private m_CurrentStrength As Integer
      Private m_Defence As Integer
      Private m_CurrentDefence As Integer
      Private m_Magic As Integer
      Private m_CurrentMagic As Integer
      Private m_MagicDef As Integer
      Private m_CurrentMagicDef As Integer
      Private m_Speed As Integer
      Private m_CurrentSpeed As Integer
      Private m_Image As Bitmap

      Public Event Charging(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.ComponentModel.ProgressChangedEventArgs)
      Public Event TurnStarted(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs)
      Public Event TurnEnded(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs)
      Public Event Killed(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs)

      Private WithEvents m_Bgw As System.ComponentModel.BackgroundWorker

      Public Sub New()
         InitializeBgw()

         SetMonsterProperties()

         If Not TypeOf Me Is BaseHumanoid Then
            SetCurrentStatus()
         End If
      End Sub

      ''' <summary>
      ''' This sub must be used to set the properties Name, Level, HP, MP,
      ''' Strength, Defence, Magic, MagicDefence and Speed of the new Monster.
      ''' </summary>
      ''' <remarks></remarks>
      MustOverride Sub SetMonsterProperties()

      Public Sub SetCurrentStatus()
         Me.CurrentHP = Me.HP
         Me.CurrentMP = Me.MP
         Me.CurrentStrength = Me.Strength
         Me.CurrentDefense = Me.Defense
         Me.CurrentMagic = Me.Magic
         Me.CurrentMagicDef = Me.MagicDef
         Me.CurrentSpeed = Me.Speed

         m_Bgw.RunWorkerAsync()
      End Sub

      Public Sub Me_TurnEnded(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs) Handles Me.TurnEnded
         m_Bgw.RunWorkerAsync()
      End Sub

      ' A lot of properties for the m_Fields after this point...
The BaseDefence is just a bunch of properties that indicate elemental defence.
VB
Public MustInherit Class BaseDefence

#Region "Magic Defense"
    Private m_AstralDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_DarkDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_EarthDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_FireDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_GravityDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_HealingDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.FullAbsorb
   Private m_HolyDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_IceDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_LightningDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_PoisonDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_WaterDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal
   Private m_WindDef As DefenceDefinition.DefenceEnum = DefenceDefinition.DefenceEnum.Normal

   Public Property AstralDef() As DefenceDefinition.DefenceEnum
      Get
         Return m_AstralDef
      End Get
      Set(ByVal value As DefenceDefinition.DefenceEnum)
         m_AstralDef = value
      End Set
   End Property

   ' Etc.
A BaseHumanoid is a monster of sorts and unless I'm Barrett from Final Fantasy VII I don't think my main hand is actually a weapon Big Grin | :-D
VB
Namespace BaseCharacters

   Public MustInherit Class BaseHumanoid
      Inherits BaseMonster

      Private m_OffHand As IOffHand
      Private m_MainHand As BaseWeapon
      Private m_Magic As New List(Of BaseSpell)

      Public Sub New()
         MyBase.New()

         SetHumanProperties()
         SetCurrentStatus()
      End Sub

      Overrides Sub SetMonsterProperties()
         ' Does nothing.
         ' This sub is replaced with SetHumanProperties. 
      End Sub

      ''' <summary>
      ''' This sub must be used to set the properties Name, Level, HP, MP,
      ''' Strength, Defence, Magic, MagicDefence, Speed, MainHand and OffHand of the new Humanoid.
      ''' </summary>
      ''' <remarks></remarks>
      MustOverride Sub SetHumanProperties()

      Public ReadOnly Property GetMagic() As List(Of BaseSpell)
         Get
            Return m_Magic
         End Get
      End Property

      ' Etc...
Time to define my Hero!
VB
Public Class Hero
   Inherits BaseCharacters.BaseHumanoid

   Public Sub New(ByVal name As String)
      MyBase.New()

      Me.Name = name
      'SetStatus()
   End Sub

   Public Overrides Sub SetHumanProperties()
      Me.Level = 10
      Me.Strength = 10
      Me.HP = 100
      Me.MP = 10
      Me.Defense = 10
      Me.Magic = 10
      Me.MagicDef = 10
      Me.Speed = 4
      Me.Image = My.Resources.super_hero
      Me.MainHand = New HealingStaff

      Me.AddMagic = New IceWhisper
      'Me.AddMagic = New FireBreath
   End Sub

End Class
And of course an actual monster:
VB
Public Class Imp
   Inherits BaseCharacters.BaseMonster

   Public Sub New()
      MyBase.New()
   End Sub

   Public Overrides Sub SetMonsterProperties()
      Me.Name = "Imp"
      Me.Level = 3
      Me.Strength = 6
      Me.Defense = 3
      Me.HP = 50
      Me.MP = 5
      Me.Speed = 3
      Me.Image = My.Resources.images
   End Sub

End Class
I also need a landscape to fight in:
VB
Public Class Forest
   Implements ILandscape

   Public Function GetMonster() As BaseCharacters.BaseMonster Implements ILandscape.GetMonster
      Dim random As New Random
      Dim i As Integer = random.Next(0, 2)

      Select Case i
         Case 0
            Return New Imp

         Case 1
            Return New Harpy

         Case Else
            Return New Imp

      End Select
   End Function

   Public ReadOnly Property BackGround() As System.Drawing.Bitmap Implements ILandscape.BackGround
      Get
         Return My.Resources.forest_wallpaper987
      End Get
   End Property
End Class
And now your wondering what this all looked like?
It looked awesome! The imp never stood a chance![^] Laugh | :laugh:
And by simply changing the area from New Forest to New Dungeon I changed the entire battlefield!
So who's going to give me a job in game development?[^] Laugh | :laugh:
The images are just random google images for forest, dungeon, imp, skeleton and hero, and I cannot give credit because I don't know the source.

So I admit, my graphical skills have not increased since then.
But oh boy, just look at that code Laugh | :laugh:

GeneralRe: This is gold (one of my first programming projects) Pin
honey the codewitch14-Sep-19 3:38
mvahoney the codewitch14-Sep-19 3:38 
GeneralRe: This is gold (one of my first programming projects) Pin
Sander Rossel14-Sep-19 4:58
professionalSander Rossel14-Sep-19 4:58 
GeneralRe: This is gold (one of my first programming projects) Pin
Richard Deeming15-Sep-19 23:57
mveRichard Deeming15-Sep-19 23:57 
GeneralRe: This is gold (one of my first programming projects) Pin
Sander Rossel16-Sep-19 0:07
professionalSander Rossel16-Sep-19 0:07 
GeneralOh come on - that's so simple to do. Pin
OriginalGriff14-Sep-19 2:19
mveOriginalGriff14-Sep-19 2:19 
GeneralRe: Oh come on - that's so simple to do. Pin
honey the codewitch14-Sep-19 3:54
mvahoney the codewitch14-Sep-19 3:54 
AnswerRe: Oh come on - that's so simple to do. Pin
lopatir14-Sep-19 4:02
lopatir14-Sep-19 4:02 
GeneralAccess doesn't do numbers. Pin
Chris C-B13-Sep-19 23:38
Chris C-B13-Sep-19 23:38 
GeneralI have lost my favourite metaphor Pin
Duncan Edwards Jones13-Sep-19 20:58
professionalDuncan Edwards Jones13-Sep-19 20:58 
GeneralRe: I have lost my favourite metaphor Pin
RickZeeland13-Sep-19 21:53
mveRickZeeland13-Sep-19 21:53 
GeneralRe: I have lost my favourite metaphor Pin
PIEBALDconsult14-Sep-19 2:04
mvePIEBALDconsult14-Sep-19 2:04 
GeneralRe: I have lost my favourite metaphor Pin
Rick York14-Sep-19 6:05
mveRick York14-Sep-19 6:05 
GeneralRe: I have lost my favourite metaphor Pin
BillWoodruff14-Sep-19 21:37
professionalBillWoodruff14-Sep-19 21:37 
GeneralRe: I have lost my favourite metaphor Pin
Duncan Edwards Jones15-Sep-19 11:48
professionalDuncan Edwards Jones15-Sep-19 11:48 
RantStupid settings Pin
lopatir13-Sep-19 20:36
lopatir13-Sep-19 20:36 
GeneralRe: Stupid settings Pin
Nelek13-Sep-19 23:29
protectorNelek13-Sep-19 23:29 
GeneralRe: Stupid settings Pin
honey the codewitch14-Sep-19 1:50
mvahoney the codewitch14-Sep-19 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.