Skip to content

Some problems with the Dungeon Slime 2D tutorial #93

@cyespace

Description

@cyespace

First of all I want to thank you guys for making the tutorials, they are very very helpful :D

ok the problems:
(1) when the bat hits a corner it speeds up, because we are using normals to check and calculate the bat's new velocity when it bounces from the wall, and when the bat hits the corner the normal is either (1,1)(-1,1)(1,-1)(-1,-1) because it's touching both walls, which has length of 2^0.5 = 1.414, so the Vector2.Reflect(_velocity, normal) will produce a greater vector. The solution is either call normal.Normalize() before passing it into Vector2.Reflect, or simply don't use normal for the bounces. I think reversing the X or Y when the bat hits the vertical or horizontal walls is good enough.

(2) in 21: Customizing Gum UI there are 2 offBackground.Dock(Gum.Wireframe.Dock.Left); in the "OFF" side of the slider section. I don't think docking it twice is necessary, is it?
Under it in the middle track portion of the slider section there is first middleBackground.Dock(Gum.Wireframe.Dock.FillVertically); and then middleBackground.Dock(Gum.Wireframe.Dock.Left); I think the last dock will just overwrite the first one..?

(3)in 22: Snake Game Mechanics the line newTail.At = tail.To + tail.ReverseDirection * _stride;
I think it should be newTail.At = tail.At + tail.ReverseDirection * _stride; here because tail.To + tail.ReverseDirection * _stride essentially equals tail.At.

(4)in 23: Completing the Game I think we need to call _ui.UpdateScoreText(_score); in InitializeNewGame(), otherwise the game score shown in the UI will not be reset until the slime catches a bat in the new game, because we only calling _ui.UpdateScoreText(_score) there.

(5) it's NOT a problem from the tutorial but I ran into the shallow copy vs deep copy issue with the SlimeSegment in 22: Snake Game Mechanics. So we are supposed to create a struct for SlimeSegment but by default visual studio creates a class when you create a new .cs file, and I forgot to change it to struct. I found out in C# (im java dev there is no struct there)the struct is deep copied while class is shallow, so later in the Slime's Move() this line
SlimeSegment head = _segments[0];
becomes creating a reference to the first segment of the slime for me, and caused a bug that instantly kills the slime. I think it's better to mention the struct vs class copy difference here too, besides the performance impact.

(6) a minor issue..it doesn't really matter but in the early tutorial when we first implement movement control for the slime, when the slime moves diagonally the speed is faster because the velocity magnitude becomes 1.414. Maybe add a note?

(7) not a problem but may I suggest adding a chapter about version control?

that's all issues I found following the tutorial.
Again much thanks, and keep up the great work :DD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions