Tag Info

New answers tagged

0

I imagine it's because you're only passing the iterators i, j, k to SetCell which will limit cell placement to 60 along all three axes, creating the outline of a cube.


0

Here is a link to a similar question on stack using unity2d to rotate a sprite. http://stackoverflow.com/questions/20058028/how-can-i-rotate-a-sprite-in-unity-4-3. Also a tutorial on sprite's rotations and animation : http://www.raywenderlich.com/66345/unity-2d-tutorial-animations.


0

If the aspect ratio remains constant, just scale the bitmaps. GUI elements might need some different handling though. For a more robust approach: Do your research into what resolutions are available for your target platforms and pick the most often used ones Create GUI configurations (ideally, purely visual rather than making more objects visible, etc) for ...


1

Short answer: probably not. Look here https://hg.libsdl.org/SDL/file/704a0bfecf75/src/render to see that there are implementations of generating real textures. It depends on devices you are targetting. When current texture is being changed you call it a change of context on graphics card. It may work worse on mobile phones to often change texture, ...


2

If you write a 1 for a connection and 0 for lack of connection, and have 8 sides, then you can write out the configuration of an octagon as a bit string. I'll order them as east, northeast, north, northwest, west, southwest, south, southeast. If north and west are connected to neighbors and other directions are not, this would be written 0 0 1 0 1 0 0 0. ...


1

Unless you want to allow octagons to overlap (when you would, you would be in quite a lot more trouble), it is impossible for two adjacent edges (a diagonal and an orthogonal) to be both connected to another tile. This makes stuff a lot easier. Separate each of your octagons into 9 tiles like this: You need one set of tiles where the diagonals are ...


1

Just like Raxvan said, generally a single large texture is the optimal way, but that does not mean you have to choose between either, at least as far as your assets go - it's not extremely difficult to write a texture packer that takes a number of images, and packs them into one or more larger textures, with a by-name or by-index lookup. Depending on how ...


1

First use Zehelvion answer to make the car turn correctly, then: Use the timestamp, you measure how much time it took for your last iteration and use that to modulate the speed at which you are changing things. void RunGame(float deltatime) { if (key.KeyCode == Keys.Up) { Player1.speed += accelaration * deltatime Player1.speed = ...


5

Start by adding a variable for the angle that the car is moving at. float angle = Math.Pi / 2; Then add a variable for the current speed. float speed = 0.0; Now create three constants: public static final float acceleration = 0.1; public static final float maxSpeed = 5.0; public static final float rotationRate = Math.Pi / 50; For starters, get your ...


13

L-Systems, from what I can tell*, are a set of grammar-like substitution rules that you can apply recursively to get interesting, "organic" results. Plants are where L-Systems are often used, as they show a lot of recursive growth (i.e. branch splits off into more branches). For a simple example, I'll show a "lollipop" tree generated using an L-System: ...


12

The short answer: Using one big texture atlas will probably be faster and should definitely not be slower than multiple small textures and here is why: After taking a look at the SDL source code i can see that SDL supports a bunch of renderers (OpenGL, Gles2, Psp, D3D ...) and (except the software one) all of them are implemented in the same fashion: ...


3

Because this game is 2D and I doubt you'd hit the limit of VRAM and unless you are swapping through thousands of textures, I don't think it makes much difference. There are benefits and drawbacks to both: Packed textures are easier to manage and can be smaller on disk (potentially in VRAM) however require math to extract the correct sub texture. ...


0

It's called a Hash data structure aka an associative array. It is often used to represent a sparse array. For instance like in your case, a huge world with myriads of tiles, that is sparsely occupied by only hundreds or thousands of units. It is very fast because it knows where to look for values (in your case units) with a certain key (in your case ...


3

There are a multitude of 3D projections out there with different properties and any 3D modelling tool worth its salt ought to be able to configure the cameras to achieve those looks. A perspective projection like the one you have used have diminishing widths and heights as you go further away, which will result in the trapezoid shape that you illustrate. ...


1

Getting null reference exception is normal since they were created in the previous scene and destroyed in the current one. To move them to the next scene, you need to call DontDestroyOnLoad. Why don't you create your assets after the scene is loaded? GameManager should be responsible for creating player and enemy objects and keep track of the game state. In ...


3

Take an arrow image without any perspective Rotate the image by the desired amount of degree Scale the image vertically.


0

I've found a solution: public void Draw(SpriteBatch spriteBatch) { //Interpreting tiles as bounds //Sub-ing and add-ing 128 just to get more tiles than visible, //so the world feels like more alive // 16 - is tile size // 128 / 16 = 8 more tiles int startX = (va.area.Left - 128) / 16; int endX = ...


0

I had similar issue, but my character stopped at some points. After adjusting rigidbody mass and physics material friction, it worked. Maybe it will work in your case.


0

This is my way for achieving this effect: void OnTriggerStay2D(Collider2D other) { Debug.Log("Object is in trigger"); player.rigidbody2D.AddForce (-Vector2.right*20000*Time.deltaTime); }


4

The sign of the dot-product of C with AB will be positive when the vector component of CD parallel to vector AB is in the direction AB, and negative when it is in the direction BA. The sign of the (z-component of the) cross-product of vector CD with vector AB will indicate which side of AB the agent is approaching from. Depending on your sign conventions, ...


2

If I understand what you're asking, the vector CD is just a vector, not a ray, so only the direction matters, not location. However, AB is a line segment, not just a vector, so its location matters. Your tests have one 'if' test to make two cases, but I think you actually have four cases. Let's look at the diagram in AB's reference frame: If you can ...


0

You have both the current position and the last position on move. (touch.position, leftFingerPos) You can do a ray cast using these to see if there is a collision with your arrow. http://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html


2

I don't have a specific example for an Isometric camera, but it sounds like you are asking about the basic camera system in general. The camera I use in my games is somewhat simple and is illustrated in the figure below: The Camera class contains the following member variables: Vector2 position; Vector2 viewport; Rectangle worldRectangle; Converting ...


5

You're on the right track. I would start by determining the player's direction based on the keyboard state: direction = Vector(0, 0) if up pressed: direction = direction + Vector(0, -1) if down pressed: direction = direction + Vector(0, 1) if left pressed: direction = direction + Vector(-1, 0) if right pressed: direction = direction + ...


1

You need to remember that C++ is a multi-paradigmatic (OOP, functional, procedural, ..) language and you should use the programming paradigm that best solves your current issue. OOP doesn't lend itself well to this problem. In OOP you think about single objects in isolation (concept of "a tile"). But most of your algorithms will operate on a whole ...


1

I would advise against using inheritance to manage different tiles. Imagine how annoying it would be having to define a new class every time you add seemingly different types of tiles. That would result in a lot of implementations for simple things like a grass or a dirt tile. It is much simpler and more maintainable to make tiles configurable. Define a Tile ...


0

(I cannot comment so I'm answering) If you build an array with reference for the types of the files (I don't know much of C++, so I'll pseudocode) tiles[0,0] = ref_to_fire_tile tiles[0,1] = ref_to_fire_tile tiles[0,2] = ref_to_grass_tile ... Where ref_to_*_tile holds a reference for a specific type of tile which inherits from a generic one, this way ...


6

It is fine to have lots of instances. An instance of a class without virtual methods is just like a POD C struct in terms of memory consumption which is similar to primitive data types. It is no problem. Your concern when instantiating many instances of a class are resource related I would think. CPU - should not be affected because you will be ...


0

To give an example to my comment public class Tile { //some variable stuff; public Tile() { //some constructor stuff; } } public class FireTile { //some variable stuff; public FireTile : Tile() { //sets player on fire //some constructor stuff ...


1

Yes, this is a fine approach - it will be orders of magnitude faster than creating a primitive per data point. Assuming single-channel data, you should use whatever DXGI_FORMAT (or equivalent in OGL) maps to your source data, and convert in the pixel shader. There are native types for 8, 16, and 32-bit integers, as well as 32-bit floats. You should also ...


1

Your best bet is to attach the debugger and see where things are going wrong. If you're getting a stackoverflow it means you're recursing too far into your CheckSquare method. That either means your map is too large, or you're checking the same tiles multiple times. I'd bet on the latter given your screenshot. Depending on the IDE you're using, you can ...


6

A typical implementation of A* will use a loop instead of recursion. Change the if (ClosedList[ClosedList.Count - 1] != End) CheckSquare(...) into a while loop. However, I suspect the code won't work correctly even with that change, because you're clearing all the data after you check just one square. A* needs all that data (OpenList, gValues, etc.) so you ...


0

Anyway, any advice? How could I make attacking and moving feel more natural? What about the hit mechanics themselves? My biggest gripe right now is: I don't think "Pick an enemy in a small circular area ahead of the player" is really good. What should I do? You could have the hit detection and movement restrictions match your attack animations. If ...


0

Creating an horizontal or vertical gradient is very simple. Anything else is going to be a little more complicated. If you are looking to strictly create an horizontal or vertical gradient, you can do it as follows. This will create a RenderTarget for a horizontal gradient: //create a blank 1x1 white texture Texture2D BlankTexture = new ...


1

If you are doing a classic 2d platformer (which you [the OP] are not [this answer is directed at people who are doing it]) then you could use something like DragonBones (open source). Even in your situation, you could make some considerations and implement something like this. If you must have the tool look perfect from a lot of angles and can't compromise ...


0

I made my inventory work with an "Item" class that ties actual game objects to their icon, description, etc. - the inventory only deals with "Items" while using an item (placing it, for example, in the game world) would consume one and then create the game object. I know that's a bit simplistic of an answer, but I felt like sharing my two cents.


0

I assume your noise is outputting height values for the terrain - the style shouldn't matter, as that's applied after the noise is done with. Add a lower octave of noise and add (or otherwise combine) them together. The lower the octave (larger amplitude and lower frequency) the larger/longer the features it creates, so to add hills you need to add that sort ...


0

I'd highly suggest you look into implementing a Quadtree. This would allow you to run a query to fetch all the objects in your viewport, as opposed to checking every single entity before a draw. Have a look at the following sample query code: List<Entity> entitiesOnScreen; entitiesOnScreen = QuadTree.GetObjects(Viewport.Rectangle); foreach ...


0

1) You don't need to calculate the visible objects in a single frame, you may use a bit bigger viewport, and calcultate only 500 objects per frame, if you have 20000 objects and your framerate is 50fps, in 40 frames you will have the right list, and it will take 0.8 secs 2) if your objects are not very complex or are static, sometimes is faster to put them ...


0

You would likely have to switch over to the 3D (lower level) rendering and then use instancing which offloads most of the work to the GPU. http://www.float4x4.net/index.php/2011/07/hardware-instancing-for-pc-in-xna-4-with-textures/



Top 50 recent answers are included