Saimaster13 wrote:Why is Swordfish better?
Great question!
One of my biggest gripes with Arduino is it's lack of 'knowing what you're talking about' For example, lets make a variable and call it 'ThisIsMyVariableThatIHaveDeclared' In Swordfish, anytime I want to reference that variable, all I have to do is type it out in lowercase and as long as I haven't made any spelling errors, swordfish will automatically put the caps in so it looks just like how I declared it. It's a very good aid in showing that you have actually typed in something that is actually there. If for some reason it didn't put the caps in, then it means I made an error while typing it out and I can fix it straight away.
Arduino however will require you to type it out EXACTLY as you did in the first place. If you for some reason forget how you typed it, you will have to scroll up to where you declared it so you can get it right, then scroll down to where you were coding and keep going.
Swordfish code is also easier to read and simpler to type out compared to arduino. For example to blink an LED in Arduino you would do this:
Code: Select all
void loop() {
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
which isn't too bad, but I think this is easier!
Code: Select all
While 1 = 1()
LED = 1
DelayMS(1000)
LED = 0
DelayMS(1000)
Wend
Swordfish also has a lot of powerful features that are lacking in arduino. like structures! perfect for making games. (even though I have only myself discovered them recently...)
Let's say you have lot's of bad guys in a game. you could make a structure called BADGUY and then give this structure a whole heap of attributes like this:
Code: Select all
structure BADGUY
Name as string
WeaponStrength as byte
ArmourStrength as byte
ShieldStrength as byte
end structure
Then once you have a structure in place, you can make a whole heap of bad guys and they will all have these attributes which you can then set and update:
Code: Select all
Dim BadGuy1 as BADGUY
Dim BadGuy2 as BADGUY
Dim BadGuy3 as BADGUY
Now you have three bad guys and they all contain the attributes seen above (I.E. they have a name attribute, weapon strength etc...)
upon creation, you could set their attributes to what you want:
Code: Select all
Dim BadGuy1 as BADGUY
BadGuy1.Name = "Barry"
BadGuy1.WeaponStrength = 50
BadGuy1.ShieldStrength = 25
BadGuy1.ArmourStrength = 60
Then in your game if you hit the bad guy you might deduct so many points from where you hit him:
Code: Select all
if YouHitBadGuy1 = true then
BadGuy1.ArmourStrength = BadGuy1.ArmourStrength - 5
endif
Then when you kill him you would write it to the LCD screen:
Code: Select all
LCD.Write("BadGuy1.Name," Is Dead")