Click here to Skip to main content
14,388,816 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 7:02
mveRick York14-Sep-19 7:02 
GeneralRe: I don't like java. Pin
honey the codewitch14-Sep-19 7:03
Memberhoney the codewitch14-Sep-19 7:03 
GeneralRe: I don't like java. Pin
Brisingr Aerowing14-Sep-19 15:29
professionalBrisingr Aerowing14-Sep-19 15:29 
GeneralRe: I don't like java. Pin
honey the codewitch14-Sep-19 15:30
Memberhoney the codewitch14-Sep-19 15:30 
GeneralRe: I don't like java. Pin
Munchies_Matt14-Sep-19 23:49
MemberMunchies_Matt14-Sep-19 23:49 
GeneralRe: I don't like java. Pin
honey the codewitch15-Sep-19 4:33
Memberhoney the codewitch15-Sep-19 4:33 
GeneralRe: I don't like java. Pin
MSBassSinger16-Sep-19 4:01
professionalMSBassSinger16-Sep-19 4:01 
GeneralThis is gold (one of my first programming projects) Pin
Sander Rossel14-Sep-19 3:50
professionalSander Rossel14-Sep-19 3: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!
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.
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
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!
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:
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:
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 4:38
Memberhoney the codewitch14-Sep-19 4:38 
GeneralRe: This is gold (one of my first programming projects) Pin
Sander Rossel14-Sep-19 5:58
professionalSander Rossel14-Sep-19 5:58 
GeneralRe: This is gold (one of my first programming projects) Pin
Richard Deeming16-Sep-19 0:57
mveRichard Deeming16-Sep-19 0:57 
GeneralRe: This is gold (one of my first programming projects) Pin
Sander Rossel16-Sep-19 1:07
professionalSander Rossel16-Sep-19 1:07 
GeneralOh come on - that's so simple to do. Pin
OriginalGriff14-Sep-19 3:19
mveOriginalGriff14-Sep-19 3:19 
GeneralRe: Oh come on - that's so simple to do. Pin
honey the codewitch14-Sep-19 4:54
Memberhoney the codewitch14-Sep-19 4:54 
AnswerRe: Oh come on - that's so simple to do. Pin
lopatir14-Sep-19 5:02
Memberlopatir14-Sep-19 5:02 
GeneralAccess doesn't do numbers. Pin
Chris C-B14-Sep-19 0:38
MemberChris C-B14-Sep-19 0:38 
GeneralI have lost my favourite metaphor Pin
Duncan Edwards Jones13-Sep-19 21:58
professionalDuncan Edwards Jones13-Sep-19 21:58 
GeneralRe: I have lost my favourite metaphor Pin
RickZeeland13-Sep-19 22:53
mveRickZeeland13-Sep-19 22:53 
GeneralRe: I have lost my favourite metaphor Pin
PIEBALDconsult14-Sep-19 3:04
professionalPIEBALDconsult14-Sep-19 3:04 
GeneralRe: I have lost my favourite metaphor Pin
Rick York14-Sep-19 7:05
mveRick York14-Sep-19 7:05 
GeneralRe: I have lost my favourite metaphor Pin
BillWoodruff14-Sep-19 22:37
mveBillWoodruff14-Sep-19 22:37 
GeneralRe: I have lost my favourite metaphor Pin
Duncan Edwards Jones15-Sep-19 12:48
professionalDuncan Edwards Jones15-Sep-19 12:48 
RantStupid settings Pin
lopatir13-Sep-19 21:36
Memberlopatir13-Sep-19 21:36 
GeneralRe: Stupid settings Pin
Nelek14-Sep-19 0:29
protectorNelek14-Sep-19 0:29 
GeneralRe: Stupid settings Pin
honey the codewitch14-Sep-19 2:50
Memberhoney the codewitch14-Sep-19 2: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.