I'm a newbie to Java.
I'm trying to create the game 2048 in NetBeans IDE.
So far I've managed to create the following:
Merging same tiles (when pressing keyboard arrows).
Moving tiles
(when pressing keyboard arrows).
Creating a new tile at a random
position with 90/10% chance of 2/4.
But!
The only thing that keeps me from finishing the game is creating the rule:
When the game stops creating a new tile?
In the image below I've shown some examples from the real game, when the game keeps the player from creating a new tile when pressing down arrow:
examples
The same applies for the rest of the directions and the keyboard keys (Left, Right, Up).
Obviously, when part/s of the last row is filled with tiles, the player is unable to create a new tile when pressing down.
Or if two rows are filled, or three.
But is there any algorithm for that rule?
Is there a specific number of tiles that are on screen that prevent from creating a new one?
Or is there a specific score-step that creates the prevention?
The game creates a new tile whenever at least one tile moves or merges.
If aTileMoved() Or aTileMerged()
createANewTile()
I'm not sure if this question is about programming (how to implement the mechanics) or if its more about 2048 (what the mechanics are).
If it is the former, then just check if any tiles moved or merged with other ones in the last move. If at least one tile moved or merged with another, generate a new one. If not, do nothing. Of course how easy that is to implement heavily depends on how you've written your game, and since you've provided no code, I cannot illustrate with an example.
If it is the latter then please refer to this help center article on what questions are on topic here.
Related
Whats going on is, I want to detect what the tile I'm clicking on is, but I'm unsure of how I can do that if my tilemap consists of multiple layers. For example, with the way my script is currently set up, the ground level 'island' can be passed into the script as the 'map' variable, but then I wont be able to see if I am clicking on the house, which is in a separate layer. I'm new to Unity so I apologize if I'm explaining it badly, but basically I need a way to look through multiple layers of the tilemap to see what is being clicked on. In the future I would want to implement some sort of system in which a tile could have some sort of modifier sprite on top of it in a higher layer, so I would want to see the tiles in both layers, another reason I'm wondering if there's a way to cycle through those tiles.
I am creating a 2D grid based game in Unity. I am using Tile maps for background (one grid and two tile maps).
On the first tile map I have the background (like grass) and on the second one I have things I add, like a hole in the ground. Now I add game objects to the scene (a sprite tree). I have two BoxCollider2D on the tree, first one is just a small one at the bottom of the tree and the other one covers the whole tree but is set as trigger (I have a script that automatically fades out the tree when user is behind it).
The problem is that the user keeps getting stuck at the collider (I think) at the bottom of the tree. It works from some angles. I tried creating a small 2D square too and sometimes I get stuck to that too. What am I missing?
I have added a custom material that has friction set to 0 on both the Player and the tree.
I don't know if it is relevant but the tree is quite big so I had to set its size to 0.5 instead of 1.
remove the interaction between the player and the tree, see in project setting, modify the script to work with a raycast
or just make the tree collider a Trigger..
Still new to Unity. I am trying to make a 3D runner game. So I have a ground that is spawning as my player moves up the map. It spawns forward. However, I would like to make my ground spawn to the right and left side of my character so that my character never falls off the map. Just an endless ground spawn. How do I go about this?
I tried doing transform but the ground would spawn in a y axis instead of building along with the original gound.
Judging from what you wrote, it seems that you are holding the wrong axis when grabbing the currently created position.
I don't know what type of runner game it is.
There is a difference in the methods you can try when the character is fixed in place and when it is freely moving on the screen.
Fixed
The character only jumps in place, and the map is continuously created left and right, and you can make it by thinking that the map moves.
If the character passes through a specific point (eg the center of the map), you can create a map in the direction it crossed.
Moving
The second method suggested when it is fixed is a general example. If you want to design a map that can move up, down, left, and right, you need to think a little more. If you create a map on the top, bottom, left, and right in a repeating form, you can try a method similar to that created on the left and right.
You can find many examples by searching for keywords such as Endless Runner on YouTube or Google.
So I want to display a floating text everytime the player opens a chest, that indicates how many coins you earned. I created the level using tilemaps. The problem arises when I created the floating text, basically it's covered by the tilemap, because if I move it out of the level I can see it, otherwise not. I tried fixing this problem by using layers, but I can't manage to make it work. Does anyone know how to help me?
As you can see by the foto the outline of the text is visible, but in play mode you can't see it.
You should probably use the order in layer in the tilemap renderer and set it to a negative value.Im sorry if it doesnt work I am new to unity.
I want to create a game with a maze(not really) in it. The whole map should be surrounded by wall and inside these walls there should be a maze. This maze should be randomly created. On every tile where no wall is placed, the player should be randomly placed. Is there a build in class/function in SpriteKit that can fulfill my requirements or do I need to come up with an algorithm by myself?
PS: A possible visualization would be the game PacMan with randomly created stages.
You can use a tile map to create your maze/levels, but you will need to write the code to do this. It will be a tough algorithm to ensure that each level is playable/winnable. Might be worth starting with defined layouts to get the game play right, then add in random generation.