Critics and Advises to BlitzMax Tutorial

Started by Midimaster, December 22, 2021, 18:29:18

Previous topic - Next topic

Midimaster

I rewised the lessons I to IV and added new challenges. Please study them and try to solve the questions.

Additional I added a soltution thread, where you can find examplary solution code for each challenge:
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/

at the moment the solutions for lessons I to III are ready.
...back from Egypt

Midimaster

#31
I added new challenges for lesson V.

Follow a Mouse slowly

Dia-Show App

Challenge III: Moorhuhn Nocturnal Hunt


Please study them and try to solve the questions.

Additional I added soltutions for this challenges (and  for lesson IV) here:
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/

...back from Egypt

Midimaster

I added new challenges for lesson VI.

Learn to code this apps:

Play a drum machine

Moorhuhn Forest Background Sound

Painting App


Please study them and try to solve the questions.

Additional I added soltutions for this challenges here:
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/
...back from Egypt

therevills

Hi Midimaster,

On Lesson XVI: More Maze Elements, the final code still is using a magic number for the player in the function FindAndMovePlayer.

I know you are introducing concepts slowing, but I would suggest a final code removing all the magic numbers and replacing them with constants.

Great job on the tutorials!

Midimaster

thanks.. i see it and will replace it immediately.

I had already written the version without any magic number... f.e. MAZE_WIDTH instead of 12. But I decided this is a too complicated step for my beginners. So I decided to do it first only for the GAME ELEMENTS.

Background was: the code needs not only 12 but also 11 and 10. So the new version contained three new things:

MAZE_WIDTH

FOR i:Int=0 UNTIL MAZE_WIDTH

Add[0, MAZE_WIDTH -2]

1.
The beginners do not know FOR/UNTIL at the moment
2.
And I would have needed an explanation why suddely MAZE_WIDTH -2 should be better than 10.
3.
And the chapter was already too long! So I removed it and will do it in the next chapters...




...back from Egypt

Midimaster

#35
I added new challenges for lesson VII.

Learn to code this apps:

Display the outer space

Produce Snow

Roll A Dice

Show three dices


Please study them and try to solve the questions.

Additional I added solutions for this challenges here:
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/
...back from Egypt

Midimaster

#36
I added new challenges for Lesson VIII.

Learn to code this apps:

Show them all

Slow Motion

Childlike Division


Please study them and try to solve the questions.

Additional I added solutions for this challenges here:
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/
...back from Egypt

Midimaster

I added new challenges for Lesson IX.

Learn to code this apps:

Number Input Function

Write a Gadget

DrawTriangle


Please study them and try to solve the questions.

Additional I added solutions for this challenges here:
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/
...back from Egypt

Midimaster

I added new challenges for Lesson X.

Learn to code this apps:

Speed Chicken

Traffic Lights

Drum Computer


Please study them and try to solve the questions.

Additional I added solutions for this challenges here:
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/
...back from Egypt

Midimaster

I revised the Lessons XX XXI, and XXII.

I replaced the oldschool CASTINGs with new style STRING METHODs:


instead of code lines like...

Code (BlitzMax) Select
...
Global PlayerAge:Int       = Int(IniRead("Age"))
Global PlayerHealth:Double = Double(IniRead("Health"))



I now use...

Code (BlitzMax) Select
...
Global PlayerAge:Int       = IniRead("Age").ToInt
Global PlayerHealth:Double = IniRead("Health").ToDouble



Please study them and try to solve the challenges.

...back from Egypt

Midimaster

#40
I defined two new challenges related to Lesson XIV: Mazes

In this challenge you can try to write a...

Chess Game

...of course only a first beginning of a chess game.

I hardly recomment to take the chance of the challenge and try to write your own solution. You will never learn programming by reading but only by doing!!!



In the second challenge you can try to write a complete...

Connect Four Game


...Here we will write a complete game. Thats not a study but the whole game!!!


Description of the contests are here:
https://www.syntaxbomb.com/tutorials/learning-basic-for-total-beginners-blitzmax-ng/msg347054258/#msg347054258


For the Chess there is already a detailed help with a detailed step-by-step solution in my Challenge thread
https://www.syntaxbomb.com/worklogs/the-challenges-to-the-tutorial/


For the Connect Four I will write the help during the next days...
...back from Egypt

Midimaster

I updates the Chess-Challenge

It follows now a new idea of handling the problem of alternating players: now the code is based only on "BLACK" move. When it is WHITE's turn the board is "rotated" and flipped, so that now WHITE is BLACK, then the decision process starts and moves the actors. At the end the board is turned back to normal state.

The advantage is that the developer need not care about current color of the player.

Old approach:
On the screen BLACK normaly runs y=y+1, but WHITE runs y=y-1. Also a move to the left looks like a move to the right for the WHITE side. You have always to take care, who is the enemy. It is -1 for BLACK player but +1 for WHITE player. This all effects in a increading number of code lines and IF-Blocks

New approach:
Now "ahead" is always y=y+1. "To the left" is always to the left. And your enemies are all always If actor<0

Therefore I revised Challenge XIV-I and wrote a new Challenge XV-II, where you can feel the advantages this has.

...back from Egypt

zelda64bit


Baggey

#43
Quote from: Midimaster on February 16, 2022, 13:25:21I revised the Lessons XX XXI, and XXII.

I replaced the oldschool CASTINGs with new style STRING METHODs:


instead of code lines like...

Code (BlitzMax) Select
...
Global PlayerAge:Int       = Int(IniRead("Age"))
Global PlayerHealth:Double = Double(IniRead("Health"))


I now use...

Code (BlitzMax) Select
...
Global PlayerAge:Int       = IniRead("Age").ToInt
Global PlayerHealth:Double = IniRead("Health").ToDouble


Please study them and try to solve the challenges.


Im following the string tutorials XX for ideas with my code converter. But i cannot get your newStyle String method to compile?

The old way works but the new way says "Method cannot be used as a function pointer" Im using the very latest Uptodate version of BlitzMaxNG release 0.136

Here is my code as is :- Which Dosent work!?

SuperStrict

Global Ini:String[]
IniLoad("ini.txt")

Global PlayerName:String   = IniRead("Name")
Global PlayerAge:Int       = (IniRead("Age")).ToInt
'Global PlayerHealth:Double = IniRead("Health").ToDouble

Print "Players name is "        + PlayerName
Print "Players age is "         + PlayerAge
'Print "Players health is "      + PlayerHealth

Function IniLoad(FileName:String)
    Local All:String = LoadText("ini.txt")
    Ini = All.Split("~r~n")
End Function


Function IniRead:String(Key:String)
    For Local i:Int=0 Until Ini.length
        Local Parts:String[] = Ini[i].Split("=")
        If Parts[0]=Key Then Return Parts[1]
    Next
    Return Null
End Function

and the old way Working?

SuperStrict

Global Ini:String[]
IniLoad("ini.txt")

Global PlayerName:String   = IniRead("Name")
Global PlayerAge:Int       = Int(IniRead("Age"))'.ToInt
Global PlayerHealth:Double = Double("Health")'.ToDouble

Print "Players name is "        + PlayerName
Print "Players age is "         + PlayerAge
Print "Players health is "      + PlayerHealth

Function IniLoad(FileName:String)
    Local All:String = LoadText("ini.txt")
    Ini = All.Split("~r~n")
End Function


Function IniRead:String(Key:String)
    For Local i:Int=0 Until Ini.length
        Local Parts:String[] = Ini[i].Split("=")
        If Parts[0]=Key Then Return Parts[1]
    Next
    Return Null
End Function

Have i missed something? I do like to try different ways of doing things with my Coding ;D

Kind Regards Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 24GB ram 1TB SSD and NVIDIA Quadro K620 . DID Technology stop! Or have we been assimulated!

ZX Spectrum 48k, C64, ORIC Atmos 48K, Enterprise 128K, The SID chip. Im Misunderstood!

Midimaster

you made only a typo:

"123".ToInt

The ToInt is a function, and so it needs always brackets:

"123".ToInt()
...back from Egypt