How best create a game map in silverlight - c#

I'm looking for some idea's on how to create the 2d layout (walk path) of a game.
The tiles will be 32x32 pixels aswell as the character moving on the tiles.
I've thought of two ways currently, havn't tried any of them out yet.
The game will be shown in a window of about 400x300 or 512x356 something.. not much bigger than that where the game map itself could be bigger then 1000x1000. So only a portion of the map will be visible most times.
So here's my 2 options as far as I've thought of them.
[1]: Create the entire map at the start (which might increase the loading times but it will make it more easy to move the map around) including each object, player, enemies etc etc.
[2]: Create only the map seen and 1 tile around it (which is not visible) so I can make that one visible with a story board and remove the row / column which is out of bounds and create a column again.
Which means, If I have a room of 5x5 tiles, and I load 7x7 tiles. If I move right, I move all the tiles left and keep the player in the middle of the screen. Then I remove the far left set of tiles and create a new set of tiles on the right side, which will hopefully be done before the storyboard has finished moving.
In the second method all I have to consider is objects that are larger then 32x32. How could I best react on those.. However, this is a problem I'd like to address later.. Right now I prefer to know people's opinions and possible better methods.
I do apoligize if this question is no apropriate for stackoverflow.

Just be careful with the "load" word. Loading, means taking the data from the disk/drive and putting it memory. For that, you should load all the current world/map at once, before the game start. Trust me, you don't want to get yourself in dynamic loading stuff while the map is running.
But you only need to load the definition of your map, you don't need to create the instance of the object at that point. So you can create the instance from the map definition as the player walks... but are you really that constraint in memory? I can understand that for a game like Minecraft or Terraria where the map contains virtually millions of tiles... But for 32x32, you can consider making them all when you load the definition.
Of course, whatever the solution, you should only draw/compute/collide/update the tiles that are visible on screen.

Related

Create a slash effect using image and progressively drawing

What I want
To create an effect like an slash in my 2D project. For that, I've an image in my assets already, and I want to draw it from top to the bottom, allowing it to be drawn in maybe half a second, progressively.
The idea is to draw it to create the effect of the slash itself, and the progressively mode is to "fit" the slash image itself, imagine the first one of the following link, that would be drawn from left to right.
To achieve that kind of drawing, the only thing that I've found is fillAmount for an Image, combined with the fillMethod.
The problem
The problem is that these methods are for the Image class, that it's not recommended for game drawing but only for UI.
Anyway, I've tried to do it this way, and I've not been able to do it, because the Unity environment didn't let me drag&drop my slash asset into the Image variable that I had created into my script. I thought that it may be because of the type of import, but also trying to import it with the other options resulted in nothing better.
The questions
Just answering one of these questions would solve my situation (or I think so):
How can I make Unity accept my image/asset into my Image object in the script?
Another way to create such effect using Sprite or GameObjects directly?
Method 1: You can use sprite sheet to create a 2D animation
1-1. Prepare a splash effect sprite sheet (an image map contains continuous action image), like
1-2. Change the sprite mode to multiple in inspector window
1-3. Slice the sprites in sprite editor
1-4. Multi-select the sprites and drag into hierarchy window, Unity will ask you to save this animation
1-5. You will get an animation GameObject
Method 2: If you can make it like a circular progress bar, check Radial/ Circular Progress Bar in unity3d

2D Procedural Generation

I'm currently trying to implement procedurally generated tilemaps for an overworld. I'm as far as generating noise and building the tilemaps using different ranges within the generated noise. However, they're very crude as each different 'biome' is just one tile. What is the best way to implement the detailing and edges of each biome? e.g flowers/trees/etc spread out in a forest biome, beach-to-water transition tiles between beach and ocean biome, etc.
For some context, I built an engine in MonoGame with a friend of mine. We implemented a chunk loading system for dynamic generation and infinite scrolling with no load screens(not exactly state of the art, I know, but I was proud of it). Each chunk is 50x50 tiles, and there are 9 chunks loaded at any given time. When the player moves chunks in any direction, the chunks on the opposite corner are unloaded and new ones are loaded in the direction the player is walking. Since the player is starting on the opposite of where chunks are being generated, it hasn't been a problem thus far as the maps are big enough that they're done generating by the time the player gets to them. I'm not sure whether the current method I have in mind is going to change this or not.
Anyway, I'm thinking that I need to determine within each biome a specific set of tiles and generate noise for each biome instance to determine placement of 'detail' tiles specific to that biome. For the edges, I'd just loop through each adjacent tile to determine whether it's a different biome. If so, use the transition tile. However, the whole idea seems very inefficient as that's a ton of noise to generate as well as looping through 7500 tiles every time the player moves chunks. I've been trying to think of a better method, but this is my first foray into procedural generation and I haven't been able to find much online that talks about anything more in-depth than generating noise and using that noise to generate chunks of land. Is there a more efficient method I should use or is my next step going to be optimizing? I can't imagine my method is going to be very efficient or practical due to how much I'm going to be looping through every tile. Anyone have any ideas or suggestions? Thanks in advance.
One idea:
Use noise to generate height, temperature, rain, ... for each chunk
Use generated values to determine the biome for each chunk
For each tile interpolate the generated of the surrounding chunks
Use the interpolated values to select ground textures, plants, ...
That should generate smooth borders between biomes and also different chunks with the same biome can have a different feel.

Most efficient way to make tall pile of objects?

Ok Im trying to make a TALL pile of objects, ideally where the outer layer/ones touchable by the user on ground level have rigid bodies and are able to be moved.
Ive succeeded using https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjem72Awa3eAhWKEZAKHbHMCBcQwqsBMAB6BAgGEAQ&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPJBPCnuaqIo&usg=AOvVaw1ewMypDbMyIV-qz8LZoo2e to make a shallow pile of objects that can move around, but no matter how many objects I drop in play mode, they inevitably bounce off each other and distribute out on the ground.
I need a TALL pile that won't all collapse - reducing polys as much as possible for gameplay, whats the best way to do this? Is there a way to use a particle system like I did with blender and a premade object:
How is this typically done in unity?
You will want to stack them in your scene, enter play mode, let them fall and come to rest then just keep going back and forth. Once you have a good stack. Clear all the random debri, then create an empty and drag all the items into it in the inspector scene view, then you can make the empty into a prefab and set pikes wherever you want.
Alternatively you can remove there rigid bodies and parent them to an empty and just add a simple block collider(if you don't want the column to come apart)

Unity 4.3 2d mode, how to make an object appear splitted on the screen if moved over the screen border

Basically in Unity 4.3 on 2d mode, I need to sometimes have objects (with sprites) that can move over the screen size border (left, right, top and bottom), when they pass the border, they should appear at the opposite like this image explain:
the first thing I had in mind was to just create a copy of the object at runtime, show it at the opposite side, and when the dragged object is completely out of the screen size, destroy that one and let only the other (new object) live. But probalby this is a bad way to do it, does exist a better way to achieve this result ?
Nope. You got it right. There is no way of the two halves appearing at opposite sides of the screen but being the same thing. Except maybe for some camera trickery but that would be for special effects, not for game logic.
Depending on what type of game you're making this will bring with it some mean problems. For instance the copy might collide with something where the original obviously will not. The trick is to apply all rules and effects from one instance to the other as well.

How can I remove the extra tiles in this grid?

I'm working on a tile-based 2D game and having a minor issue with the map generation.
The general concept is that it creates one room by default and then builds off of any existing rooms until X number of rooms have been built or Y number of tries have failed.
The issue I'm coming into is probably simple and I just can't wrap my mind around it, but how would I go about removing the circled tiles? Each map generated is procedural, so I won't know exactly when spots like the circled ones show up and I can easily spot them with my eyes... I just can't think of an all encompassing way to handle them AFTER the map is already generated.
The goal is to never have walls doubled up where they aren't needed to be. I am not wanting to change the way the map is generated, but rather modify it after the fact. I also do not want to lose corners of rooms or similar.
I really feel like what I'm trying to do would have a name in image editing or similar, but that's certainly not my forte.
Your circled items are ambiguous because in certain situation you could remove the one circled by you or the otherside without breaking the rules (no mixing rooms neither open to external black tiles).
In any case I should think a little bit more about it but they just seem the tile that after being removed don't join two rooms neither have any adjacent (diagonal included) black tile.
I guess you could assign to every room a number and then remove any tile that:
doesn't connect two floor tiles with different numbers
neither have ajacent black blocks
Maybe you could do it also without numbering rooms but you will have to understand if all neighbours are from the same room or not by exploiting side adjacency.
I'd comment instead of answer if I could, as I can't I'll give an answer a go.
How're you storing the details of the level? You seem to want to know where two horizontal or two vertical walls are touching and delete them as long as they aren't corners.
It seems like you need a rule or two like...
if it's a horizontal wall and there is a tile either side, delete any above or below.
if it's a vertical wall and there is a tile above and below, delete any to the left or right

Categories

Resources