I'm making a Unity version of Daniel Linssen's Ludum Dare 34 game Reap

Wow, that looks like a comprehensive article. Thanks. I’ll take a look at it when I get home.

1 Like

yay more information :smile: that article is great and now I learned something new also :slight_smile:

1 Like

Version 0.4.0 is out!

For this version I did a lot of refactoring to make it easy to add the remaining items, while staying as true as possible to original code. I’ve added all the items now I think, but only the map has functionality, the rest can only be picked up and dropped.

Just like with the world generator I was able to more or less directly copy-paste the code for the map from GameMaker into Unity. In GameMaker the map is drawn to a surface, but in Unity I’m drawing it to a texture using SetPixel() and then I create a sprite from that texture.

I have a couple of really challenging tasks ahead of me now and it would be amazing if anyone has any tips for me on how to solve them:

  • The map is missing the markers for the pieces of the treasure map (the “goal” of the game). These markers are sprites and I need to find a way to place these into my map texture, “splat” is perhaps the correct term?
  • I need to draw a lot of lines, circles etc. for the UI that are confined to the pixel grid, ie. no anti-aliasing and sub pixel stuff. I have no clue how to draw like this in Unity, but I’m guessing I need to access some low level stuff like this (Unity - Scripting API: GL)?
  • I need like a vignette shader that is confined to the pixel grid to simulate the peephole-functionality of the original game. I have no clue here, but I’m guessing I can find some help regarding the pixel grid stuff in the built-in sprite shader seeing as it has a “pixel snap” option.

I would really appreciate it if anyone had any tips or pointers regarding the above problems as I fear I will be spending a lot of time trying to find solutions for these. :slight_smile:

Changes for version 0.4.0:

  • Added the map. Hold the use key while holding it to view it. The only thing missing is the markers for the pieces of the treasure map.
  • Added all the remaining items as well, I think. You can pick them up and drop them, but their functionality is not implemented yet.
  • Changed the game resolution to 1280x720 to stay true to the original game. I’ll begin working on the UI soon and I want to make sure I’m working at the correct resolution from the start.

More interesting discoveries:

  • GameMaker has a special shorthand for for-loops called repeat. You just write repeat(x) {} and the code within the brackets is repeated x amount of times. In Unity I’ve replaced this with for-loops, obviously.
  • GameMaker also supports includes so you can pile all the code for something like the player onto the player object(prefab), but by separating the code out into separate scripts that are included where they are needed the whole thing ends up looking fairly neat. C# does not support this and my scripts are starting to become very long. In the future I will break it up into separate classes to alleviate this. I use PHP at work, which also supports includes, and I like them. :frowning: I’m still not very familiar with object oriented programming.
2 Likes

regarding the vignette shader, have you looked into UI mask? it may give you what you want :smile:

Thanks for the tip. I looked at it now and I don’t think I can use it as is, but it seems to be using stencil buffers/shaders which is probably what I want, but I’ve spent a few hours now fiddling with it without getting anywhere. I guess this can take a while. :stuck_out_tongue:

The problem is obviously that I have no clue how to write shaders so I’m just googling and copy/pasting other peoples code trying to make something happen, but I guess I actually have to read up on this and try to make something from scratch.

maybe this can help :smile:

okay so I tested it to try out if that could work and tadaaa it did :smile:

so what I did is I created a new image in photoshop set first layer to transparent and second i filled with white,
then I created a layer mask and made a circle gradient from black to white (middle as black), I’m pretty sure this works also by just cutting a hole into the white surface with heavily blurred edges to have that gradient effect.
then I saved that image as png with transparency into my unity asset folder.
In Unity I was setting up a new Material which I set to Unlit/Transparent Cutout and added my texture into it. Now I could use the alpha cutoff to make it appear as if the circle closes and opens :smile: (this can be modified by script btw)
Then I created a new Image in the scene (for canvas) and added for source image my texture and for material the one I had just created. Then made sure that the images position is on 0,0,0 and then happy circling :smile: the material cutoff works directly on the image inside the canvas aswell :slight_smile: so now you should have it on your screen and even as ui element :smile:

Not if you use PixelSurface. :slight_smile: Splat textures into your pixel-perfect surface (just as you do in GameMaker!) using DrawTexture. Use FillRect, FillEllipse, and DrawLines to draw lines. When you need to get or set individual pixels, you can very efficiently do that too.

It’s designed for exactly this sort of thing, precisely because the built-in functionality of Unity doesn’t make it very easy. And if you find there is any functionality lacking, just let me know — I’m eager to make it better.

And for the vignette, if I understand correctly what you want, I would simply layer a second PixelSurface in front of the first, and draw a nice transparency gradient (perhaps using a series of FillEllipse, or using SetPixel with a function based on distance from the center) in that.

Best,

  • Joe

@Farelle Thanks for the link and the mini tutorial. :slight_smile:

But I think I would really like to avoid using a texture for the effect as I consider that a bit of a hassle, and I think it will be really hard to control. So far I’ve managed to programatically draw a circle in a shader although I’m not entirely sure which part of the shader that does it, but I guess I only need a cutout shader, not a stencil thingy, it’s probably easier for me as a complete shader noob to fiddle with a cutout shader.

@JoeStrout That does look neat, but I’m giving this project away with full source code so I guess I need to figure something out myself. Perhaps I’ll consider buying it to learn from it, but I’ll consider that a last resort. :stuck_out_tongue:

Great article by the way, I finally read it. I’ll add it to the collection on my website when I have some time.

1 Like

OK, that’s a good point. You can’t generally open-source Asset Store plugins (including mine ;)).

Well, in the end it is fundamentally just textured quads. You’ve already found GetPixel/SetPixel, which are easy to use though not terribly efficient. You want to do things like batch SetPixel calls so you only call Apply once, or use SetPixels to set many at one time.

Unity doesn’t have any drawing routines (lines, curves, etc.) for textures built in, so you’ll need to look up how those are done (see here for example).

One thing’s for sure: you’re going to learn a ton from this project, and definitely level up your skills!

@JoeStrout Thanks for the tips and I’m sure you’re right, that is if I’m able to complete the project at all. :stuck_out_tongue: I knew going in that some parts would be tough, especially if my goal is to perfectly recreate the original game, which is obviously is.

The UI and the day night cycle is coming along, but I just realized my motion is much smoother than in the original game. At first I couldn’t understand why because there is no sub pixel movement there, but then I realized that when you define 1 pixel to be 2x2 pixels in GameMaker then that’s actually how all the game logic and everything behaves, but in Unity you only render it that way, everything still moves according to the normal pixels which are “half pixels” compared to the rendered output.

Not sure how to best fix this. I’m thinking either some render texture trickery or actually define my own rounding functions which rounds everything to even pixels or something like that. :stuck_out_tongue:

1 Like

Now we’re getting somewhere.

@Farelle Thanks again for the tip about the cutout shader. I’m doing this with an UI image with a cutout shader on it now. Now I need to figure out how to get the black outline and how to render stuff at 2x2 pixels.

hm…maybe it could be simply a circle (line)image without any filtering(to keep the pixelated look) and transparency put on top which you could just adjust it’s scale? or you create it with the same technique with the cutout shader, rendered behind the current one and being always a little bit more closed then the top one to create an outline effect.

btw.: I wished I would have the same easyness making POCs for your game, for my own game XD bleh, even though your game project is definitely not easier XD

have you stopped with porting further?

Heh, a bunch of people have e-mailed me and asked that same question.

Most of my hobbies are very passion driven and I lost the interest for Unity back in February. This happens at least a couple of times a year for me so it’s nothing new. Usually it’s a cool tutorial or something that brings me back, but the last few days I’ve actually been updating Unity and the project to the latest version and I’ve at least opened it again. I’m trying to figure out where I left off and what’s left to do. Once I figure that out I’ll try to restart it again and finish it.

So hopefully you’ll hear from me sooner rather than later. :slight_smile:

2 Likes

That is very nice to hear. It is a cool gameidea and very intersting to see how you develop it in unity.

And i also have to say thank you very much to your stealth tut port, great work!!! :slight_smile:
It was the first tutorial i accomplished using unity and it’s a great example which you have made nicer and more polished than the original.

Version 0.5.0 is out!

I feel like I’ve finally gotten the ball rolling again and I’ll try my best to keep this momentum going. I know this update was small, but I had to reinstall GameMaker, learn it again, refactor a ton of code and get comfortable with Unity again to make this happen. The next update will be more substantial and will happen quicker.

I know I was working on the cutout shader and proper pixel scaling when I stopped many months ago, but I just had to comment all that out to be able to get back into this project again because I just didn’t remember anything about it. I may just postpone that until the end because it’s definitely the hardest part of this project. I’ll implement all the systems and game functionality first.

Changes for version 0.5.0:

  • The gamepad triggers are working just like in the original game now. At least for xbox 360 controllers on Windows as that’s all I’ve tested.
  • The turnips and logs now have random sprites for when they are dropped.
  • All the items have proper sprites and positioning for when they are carried now.
2 Likes

hey great that you are on track again! :slight_smile:
I also think it’s better to focus on the gameplay aspects in the first place and postpone the graphical details for the finetuning at the end.

1 Like

Version 0.6.0 is out!

Almost every item can be interacted with now. The only major gameplay functionality that remains is for you to be able to look at the completed treasure map and locate and dig up the treasure so you win the game. Apart from that there’s a lot of visual polish and I have to implement time, food and energy.

Changes for version 0.6.0:

  • The shovel can now be used to dig the ground for planting turnips.
  • Turnips can now be planted. They don’t grow because there’s no implementation of time yet.
  • Turnips can be eaten. They don’t do anything because food isn’t implemented as a stat yet.
  • The markers for the treasure map pieces are now drawn on the map.
  • The treasure map can now be assembled if you gather all 4 pieces. It can’t be interacted with yet.
2 Likes

Version 0.7.0 is out!

Everything is basically in the game now. The only thing missing is the survival aspect with food and energy and the polish.

For this version I spent a ton of time trying to match every single particle effect exactly to the original game. I had to rewrite my custom sprite animator script to be framerate dependent to get the results I wanted, but as a result my port is now even more similar to the original game.

I also made the first “major” change to my port compared to the original GameMaker game. In the original game the treasure map is created by running a nearly identical version of the world generation for a small section of the map and then saving that as a sprite. There’s no reason I couldn’t do the exact same thing in Unity, but from the start I knew I wanted to try doing it with a render texture because I’ve never tried that before. In my version I just position a second camera over the treasure chest and then set it’s viewport to be 160x160 pixels just like in the original game and then render what that camera sees to a sprite. This was very simple and much less code than in the original game. As a bonus it also ensures that all the trees, rivers etc. are identical on the treasure map and in the game world, while in the original game they use different sprites because they are generated with different randomization seeds.

Changes for version 0.7.0:

  • You can now view the treasure map and use it to find and dig up the treasure to win the game.
  • All the particle effects have been added.
  • Turnips can be reaped with the hoe. They still don’t grow, but you can recover the one you planted.
  • The bridges are now animated.
  • I’ve rewritten my custom sprite animator script to be framerate dependent to ensure everything is as similar as possible to the original game.
2 Likes