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.
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
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!
Private m_Name AsStringPrivate m_Level AsIntegerPrivate m_HP AsIntegerPrivate m_CurrentHP AsIntegerPrivate m_MP AsIntegerPrivate m_CurrentMP AsIntegerPrivate m_Strength AsIntegerPrivate m_CurrentStrength AsIntegerPrivate m_Defence AsIntegerPrivate m_CurrentDefence AsIntegerPrivate m_Magic AsIntegerPrivate m_CurrentMagic AsIntegerPrivate m_MagicDef AsIntegerPrivate m_CurrentMagicDef AsIntegerPrivate m_Speed AsIntegerPrivate m_CurrentSpeed AsIntegerPrivate m_Image As Bitmap
PublicEvent Charging(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.ComponentModel.ProgressChangedEventArgs)
PublicEvent TurnStarted(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs)
PublicEvent TurnEnded(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs)
PublicEvent Killed(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs)
PrivateWithEvents m_Bgw As System.ComponentModel.BackgroundWorker
IfNotTypeOfMeIs BaseHumanoid Then
EndIfEndSub'''<summary>''' This sub must be used to set the properties Name, Level, HP, MP,
''' Strength, Defence, Magic, MagicDefence and Speed of the new Monster.
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
EndSubPublicSub Me_TurnEnded(ByVal sender As BaseCharacters.BaseMonster, ByVal e As System.EventArgs) HandlesMe.TurnEnded
EndSub' A lot of properties for the m_Fields after this point...
The BaseDefence is just a bunch of properties that indicate elemental defence.
#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
PublicProperty AstralDef() As DefenceDefinition.DefenceEnum
EndGetSet(ByVal value As DefenceDefinition.DefenceEnum)
m_AstralDef = value
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
Private m_OffHand As IOffHand
Private m_MainHand As BaseWeapon
Private m_Magic AsNew List(Of BaseSpell)
' Does nothing.' This sub is replaced with SetHumanProperties. EndSub'''<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.
PublicReadOnlyProperty GetMagic() As List(Of BaseSpell)
Time to define my Hero!
PublicSubNew(ByVal name AsString)
Me.Name = name
Me.Level = 10Me.Strength = 10Me.HP = 100Me.MP = 10Me.Defense = 10Me.Magic = 10Me.MagicDef = 10Me.Speed = 4Me.Image = My.Resources.super_hero
Me.MainHand = New HealingStaff
Me.AddMagic = New IceWhisper
'Me.AddMagic = New FireBreathEndSubEndClass
PublicFunction GetMonster() As BaseCharacters.BaseMonster Implements ILandscape.GetMonster
Dim random AsNew Random
Dim i AsInteger = random.Next(0, 2)
EndSelectEndFunctionPublicReadOnlyProperty BackGround() As System.Drawing.Bitmap Implements ILandscape.BackGround
VB.NET, not even VB 1 through 6
Although my very first code was in VB4, some 25 years ago (when I was 7 or 8).
I remember writing a quiz in WinForms with questions like "What is this? [image]" and then answers like "dog, cat, whale".
I kept the score and after 10 questions you'd get a (correct) score.
My dad was so proud he even told his customers about it (who'd later become my customers too)
After that I wouldn't write another letter of code for about 20 years and then I wrote the RPG code (the quiz code has long been gone)
Nowadays, my code just glues all kinds of (Azure) services together.
Adventures in 3d design: a continuing frustration.
I'm trying to design something - fairly complex, it's a lid for my Sous vide tank - in Fusion 360, and I'm getting the hang of things, I think. But ... I'd like to check my measurements (and in particular the internal radii) before I even think of buying a 3D printer, much let commiting to actual ABS / PLA.
So ... I'll print a one-to-one paper version of the drawing so far and lay it on the physical object. Easy!
Except Fusion 360 doesn't have a "print to paper" option, even for sketches. You can "Print to 3D" really easily, but not to paper.
It does have a "image" creation which asks for dpi, so I'll try that. Load it into Paintshop Pro for printing and ... it's not to scale, or even close.
Sent from my Amstrad PC 1640 Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!