Tag Info

Hot answers tagged

12

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: ...


6

The short answer: Using one big texture will probably be faster and should defiantly 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 suports a bunch of renderers (opengl, gles2, psp, d3d ...) and (except the software one) all of them are implemented in the same fasion: 1:BindTexture, ...


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 ...


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 ...


5

I have good news and bad news for you: The Bad News: I don't know or remember any Java library that does what you want The Good News: It's really easy to implement this type of algorithm yourself! Here's a couple, you can mix them to optimize your collision detection depending on the type of shape. BB Collision Detection You can imagine a box around ...


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 + ...


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, ...


3

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 ...


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. ...


3

As already pointed out in the comments and answer: This can be arbitrarily complex. Particularly, depending on the exact use case and performance requirements, you can employ some rather sophisticated data structures in order to make these tests fast. The bounding box test is the simplest one that should be done in any case (and in fact, could already be ...


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. ...


3

Rigidbodies can be said to operate in two modes: Non-Kinematic has physics driven movement, the physics engine will consider any forces brought to bear on the object to calculate and apply changes to velocity, rotation and position. Kinematic lacks physics driven movement, the physics engine will not cause this object to move and any forces on the object ...


3

A few things catch my attention off the bat. First: filedata = sr.text.Split('\n').Select(s=>s.Split(',').ToList()).ToList(); Feels highly dubious to me. Are you sure this is doing what you expect it do be doing? Second: float halfWidth = mainCamera.aspect * (mainCamera.orthographicSize/100); float tempYOffset = ...


2

[EDIT] As your question, now clearer seems to be more about design and not so much a technical question I change my answer a bit. Your first attempt was the right one. Your sprite contains a drag&drop component. But it's necessary that it also contains the prefab it will instantiate once dropped in the game world. The main design is, from an inventory ...


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 ...


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 ...


2

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


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 ...


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 ...


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 ...


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 ...


1

Invisible: Don't add any components that render to the screen, i.e. mesh renderer, sprite renderer, line renderer, etc. Collidable: Add a physics collider to the object and set the bounds how you like. Non-solid: Make the collider a trigger. Triggers will trigger a collision event, but won't have a collision response, essentially making them non-solid ...


1

yeah, all solutions have already been made... i'll just add some more code (i'm rather from stackoverflow ^^) assuming you're using bounding box assuming you use plain java (java.awt) . List<Shape> shapeList = ...; //you know where you get them Shape exampleShape = shapeList.get(0); Rectangle2D boundingBox = exampleShape.getBounds2D(); see ...


1

If you know the canvas is a rectangle then this simplifies to the case of checking if the bounding rectangle of the shape being drawn is contained within the canvas' rectangle. That's a fairly efficient check to run, and (generally) finding the bounding rectangle for your shape should be fairly easy (just finding the minimum and maximum x and y coordinates) ...


1

You could Create one Sprite Card Object. Give it the the four suit textures, face card textures, and card background texture. Example : for the 7 of spades you would draw the spade texture at 7 different locations with a white texture of a card in the background, and use DrawString to Draw the 7. That way you could (in your game class) say Card card = new ...



Only top voted, non community-wiki answers of a minimum length are eligible