Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411474 Posts in 69369 Topics- by 58423 Members - Latest Member: antkind

April 23, 2024, 01:27:02 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityTownhallForum IssuesArchived subforums (read only)TutorialsOtter 2D Tutorial Series
Pages: [1]
Print
Author Topic: Otter 2D Tutorial Series  (Read 6523 times)
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« on: March 23, 2014, 12:08:26 PM »

About a month ago I wrapped up a tutorial series on the new SFML.NET, 2D game framework, Otter.

The tutorial is geared more for beginners, and doesn't present anything advanced. Its intents are to help anyone new to game development, or even just Otter, quickly get something on the screen, and learn a few things while doing so.

Otter 2D Top-Down Adventure Tutorial
Part 1: An Intro to Otter2D, a 2D Framework Using SFML.NET
Part 2: Creating Your First Scene
Part 3: Polishing our TitleScene
Part 4: Adding the Player Entity
Part 5: Sound Effects, Particles, and Screen Shake
Part 6: Enemies and Collisions
Part 7: Introduction to Tilemaps
Part 8: Creating a "Zeldalike" Camera
Part 9: Adding a Boss and an EndScene
Part 10: Polish and Final Thoughts

Looking back, I realize it probably would've been a good idea to start this thread when I first started releasing the tutorial on a weekly-ish basis. Ah well, better late then never. Lastly, feel free to discuss here, or in my forum post on the official Otter forums.
Logged

eyeliner
Level 10
*****


I'm afraid of americans...


View Profile
« Reply #1 on: March 26, 2014, 03:19:51 PM »

This is exactly what I was needing!

Thanks very much! Bookmarked for safekeeping.
Logged

Yeah.
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #2 on: March 26, 2014, 04:36:13 PM »

This is exactly what I was needing!

Thanks very much! Bookmarked for safekeeping.

Haha, no problem. If you run into any issues let me know.
Logged

hurrakan
Level 0
*


View Profile
« Reply #3 on: May 07, 2014, 03:51:36 AM »

Many thanks for these tutorials!

However, I encountered a few confusing problems...

In Tutorial 4 - Adding the Player Entity:

Code:
// Player.cs

// These lines give an error and wont compile because the third parameter has to be a float
sprite.Add("standLeft", new int[] { 0, 1 }, new int[] { 10, 10 });

// I changed it to the following, which seemed to work:
sprite.Add("standLeft", new int[] { 0, 1 }, new float[] { 10f, 10f });

I also got confused by the paragraph below:
Quote
Next, we must check if these keys are being pressed in the Player.cs class, and handle the input accordingly. We must also play the proper animation in our spritesheet, that corresponds with the current input. This is all done in our Update method, which you should modify to look like so:
It was confusing because the Player.cs class did not already have an Update() method defined. It might be clearer to use the word "create" instead of "modify".

Running the tutorial does not work - no bullets are fired. After I downloaded the complete source code for this tutorial, I found that there was more code that was not mentioned within the tutorial:
Code:
// Player.cs
public int direction = 0; // tutorial text does not mention this required line

public Player(float x = 0, float y = 0)
{
   direction = Global.DIR_DOWN; // tutorial text does not mention this required line

Also, in the Player.cs Update method, the direction needs to be set for each key:
Code:
// Player.cs

public override void Update()
{
   if (Global.PlayerSession.Controller.Left.Down)
   {
      X -= moveSpeed;
      sprite.Play("walkLeft");
      sprite.FlippedX = true;
      direction = Global.DIR_LEFT; // tutorial text does not mention this required line
   }

Also the tutorial text does not mention that the following code needs to be added to the Player.cs Update method:
Code:
if (Global.PlayerSession.Controller.X.Pressed)
{
   Global.TUTORIAL.Scene.Add(new Bullet(X, Y, direction));
}

Finally, when adding the game scene music, the tutorial text says to add a line of code to "Global.cs", which is incorrect. The code actually needs to be added to "Assets.cs":
Code:
public const string MUSIC_GAME = "../../Assets/Music/game.ogg";

It would be helpful if these mistakes could be corrected. Thanks again Smiley

One final point - the player can move in 8 directions but the bullet can only shoot in 4 directions...
« Last Edit: May 14, 2014, 01:38:07 AM by hurrakan » Logged
hurrakan
Level 0
*


View Profile
« Reply #4 on: May 07, 2014, 05:40:18 AM »

I found some problems in Part 5:

The bullet animation only seemed to display the first frame. This was because the tutorial text did not mention that the line below needs to be added to BulletParticle.cs:
Code:
public override void Update()
{
   base.Update();

   Y -= (float)(1.5 / Otter.Rand.Float(1, 3));

   if (sprite.CurrentFrame == destroyFrame) // the tutorial text does not mention this code
   {
      RemoveSelf();
   }
}

When adding the camera shake, the tutorial text does not mention that the following code must be added to Global.cs:
Code:
using OtterTutorial.Util;

The tutorial text does not mention that the following code must be added to Bullet.cs:
Code:
using OtterTutorial.Effects;

When adding the walk particles to the Update method within Player.cs, the tutorial text does not mention that two additional variables have to be added to the Player class, above the constructor:
Code:
public class Player : Entity
{
   public const int WIDTH = 32;  // tutorial text does not mention this line
   public const int HEIGHT = 40; // tutorial text does not mention this line

Thanks Smiley
« Last Edit: May 07, 2014, 06:27:24 AM by hurrakan » Logged
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #5 on: May 07, 2014, 08:18:21 AM »

I'll take a look at these issues soon! Thanks for pointing them out. It is always great to have another set of eyes on my writing.

Interesting that some of the stuff no longer compiles. Are you using the latest version of Otter? If so, perhaps some updates broke the tutorial.
Logged

hurrakan
Level 0
*


View Profile
« Reply #6 on: May 07, 2014, 09:45:53 AM »

No problem Smiley

Yeah, I assumed some of the Otter code must have changed since you wrote these tutorials. Unfortunately I could not find an Otter changelog.

I don't actually know C# etc. so I was getting quite confused at times. But the complete source downloads at the end of each tutorial helped me to work out what was wrong.

I am enjoying these tutorials though, and this Otter stuff seems very promising.

I'll keep posting any issues I encounter (found a few more in part 7).
« Last Edit: May 14, 2014, 01:38:22 AM by hurrakan » Logged
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #7 on: May 07, 2014, 10:01:04 AM »

Sounds good. I'll give you credit in the posts for helping keep these up to date with Otter's changes. I probably won't be able to get around to these fixes until later this week, but they will be made.
Logged

hurrakan
Level 0
*


View Profile
« Reply #8 on: May 07, 2014, 10:04:53 AM »

A few problems in "Part 7 Introduction to Tilemaps".

Below the section where the LoadWorld() method is shown, the tutorial text states:
Quote
We’re close to getting tiles onto the screen, but we’re not quite there yet. We just introduced a call to three more methods that currently haven’t been implemented. They are the CSVToString method, and the two LoadFromCSV methods that we need to create in the Tilemap.cs and GridCollider.cs Otter classes. First, let’s code the LoadFromCSV method. This method takes in a simple CSV string and converts it to a standard string while adding line breaks in the proper spots. Here’s our new method:
But then the method shown is actually CSVToString(). The bolded text in the above paragraph should be corrected to read: First, let’s code the CSVToString method.

When adding some variables to the Player.cs Update method, the tutorial text does not mention that the following "using" statement is required at the top of Player.cs:
Code:
using OtterTutorial.Scenes; // tutorial text does not mention this line

Finally, when I tested the game at the end of this tutorial it crashed when the Enemy sprite collides with the solid tiles. This could be prevented if you change the part where the Enemy sprite is added to the scene in Part 6  - so that the enemy is placed at coordinates where it wont collide (as we have not yet coded the Enemy collisons).
« Last Edit: May 14, 2014, 01:27:24 AM by hurrakan » Logged
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #9 on: May 07, 2014, 05:02:56 PM »

Thanks again for the edits. Besides a few of my idiotic typos that I thought I caught, it sounds like I need to spend some time with the latest Otter updates and modify the tutorial accordingly. Thanks again!
Logged

hurrakan
Level 0
*


View Profile
« Reply #10 on: May 14, 2014, 01:36:37 AM »

I can't complete tutorial 7 because of a crash:
Quote
An unhandled exception of type 'System.NullReferenceException' occurred in Otter.dll

Additional information: Object reference not set to an instance of an object.

The crash is NOT caused by the enemy colliding with a solid tile (as I thought in my post above). It seems to be due to these lines in Player.cs:
Code:
if (!checkScene.grid.GetRect(newX, Y, newX + WIDTH, Y + HEIGHT, false))
When testing the code, it runs normally until the player tries to move.

I don't know how to fix this one heh.
Logged
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #11 on: May 14, 2014, 03:53:59 AM »

Yea, I think my tutorial is pretty hosed from some Otter changes Sad

Kyle has a few graphics rendering updates coming soon, so once those are in place I'll implement all of the necessary fixes.

Do the downloadable zip files still compile and run?
Logged

hurrakan
Level 0
*


View Profile
« Reply #12 on: May 14, 2014, 04:22:38 AM »

Do the downloadable zip files still compile and run?
Only parts 1, 2 and 3.

Parts 4 and higher do not work because of the sprite.Add() calls.

Parts 7 and higher do not work because of the checkScene.grid.GetRect() calls.
Logged
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #13 on: May 23, 2014, 11:45:04 AM »

Kyle's released a massive update to Otter. I should finally be updating the tutorials over the course of the next week.
Logged

ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #14 on: September 29, 2014, 08:08:18 PM »

So it has been a long time (waited until I thought Otter was very close to v1.0), but I finally got around to updating the first seven parts of my Otter tutorial series, now supporting Otter v0.9.6. I should finish the updates for parts 8, 9 and 10 some time tomorrow. Thanks again for pointing out the issues.

Edit Parts 8, 9 and 10 have been updated. I also made note of the latest updates in v0.9.7 in a few of my posts, where applicable.
« Last Edit: September 30, 2014, 06:35:22 PM by ericmbernier » Logged

drguildo
Level 0
**

hi.


View Profile
« Reply #15 on: November 01, 2014, 05:10:23 AM »

Thanks a lot for writing these. Otter seems very promising but I tend to think that a library is only as good as it's documentation.
Logged

bury: i feel like grown men have spoiled ponies for me.
ericmbernier
Level 3
***


Sometimes I make games.


View Profile WWW
« Reply #16 on: November 01, 2014, 06:20:51 PM »

@drguildo I agree. Otter was pretty cool to work with in my tutorials, but I've opted to work with HaxeFlixel in my current project, due to the size of the community, documentation, etc. Regardless, thanks for the kind words, much appreciated!
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic