Hi iam trying to build a game in which the skater will skate on the irregular terrain which is 2D and side scrolling. Iam not getting how to instantiate a terrain dynamically and in different shapes along x-axis.. I want to achieve something like this http://thegoldenmule.com/labs/TerramorphicGenesisAlgorithms/. Please help.
Assuming you're referring to the 'circle hill' setting on the demo you linked, here's what I'd try:
Step 1: generate some nice 1D noise. My guess is the linked demo is only using two octaves, so I'd start with that. These points will end up being spread apart when you generate pixels for the actual line. It looks like the linked demo had them about 50 pixels apart.
Step 2: use spline interpolation to get values between the points generated in step 1.
To get a sense of how this works, try this demo (make sure to change the setting to cubic spline though). You'll probably need to experiment with the parameters of step 1. My hunch is you'll want to avoid noise that it too erratic & you'll need to space the resulting points out a bit. Something like this:
Alternatively, when I was looking for a spline demo/library, I came across Curvy - it might provide what you want & save you the time of rolling your own code. If not, there are probably other spline libraries out there that might work.
I spent quite awhile looking for this and couldn't find much. I finally decided to create my own solution - if you are trying to accomplish this in Unity, I created an asset which will do this for you. For some of the theory behind it, Prime 31 has a good youtube video that explains the general approach to take.
Try this asset from unity asset store.
This is very small, easy to use. Although graphics is pretty bad, you can put some shader or pp effect.
Related
So i have already asked about this on the unity forums but i thought i'd ask here too.
Basically i want to create a hexagonal shaped plane object to create terrains, however the "plane" gameobject is square, could anyone point me in the right direction of how to do this?
Thanks in advance
find any hexa plane.obj or even .fbx online , or create it by any builder asset or using unity pro builder.
here is a hexagon.obj
https://drive.google.com/file/d/1K32bE6Kb22u3rt2hl3zoAuqUOvCZlT-r/view?usp=sharing
You can use Unity's Pro Builder Asset to create custom meshes for your game.
Here is some information about it: https://unity3d.com/unity/features/worldbuilding/probuilder
You have a few options....
First of all, does it have to be hexagonal, or just look hexagonal?
You could potentially use a texture with alpha transparency to make it appear hexagonal (although it would still be a full plane for all practical purposes, eg colliders).
Short of that, you need to create a custom mesh (model).
Again, there are lots of ways you can approach this. It's possible to do from inside Unity using code. This is very flexible, but pretty advanced.
Much simpler for now would be to use an external modelling tool (Blender is free and highly thought of).
Whatever you pick, it will almost certainly have a Polygon circle command that will allow you to specify how many points it should use.
Simply enter 6 here and you'll get a perfect hexagon.
Save as .fbx somewhere in your unity project. Unity will import the model and you can then drag it into your scene.
I have an image processing question, using C#.
Say I have some schematic diagrams in BMP format, the diagram contains component shapes which are connected to each other.
I wrote a simple program to detect square shapes in the diagram as one component, and record the location of it. However, the next level is to detect more complicated shapes like a few arcs joined together. Note that these shapes can be different sizes in the image. Does anyone know any good method of doing it? without downloading any library (this is my limitation now).
After detecting the shapes, I also need to record which shape is connected to which, so later on, I can redraw them. I have one week to do this, so thanks a lot for any help!!
I'm using C#.
Have a look at this paper. My understanding of their approach:
Detect edges
Detect corners by looking for perpendicular edges
Detect polygons by looking for groups of corners
Detect circles using Hough transform
This is a fairly difficult research problem. Even with a powerful computer vision library like OpenCV, implementing an effective solution within 1 week would be a demanding task.
Have you taken a look at using EmguCV? It is an open-source C# wrapper of OpenCV. It also has a shape detection sample you might interested in.
To answer an old post I had, I have done what I needed to do in 2 weeks time, it worked well. I actually ended up using different algorithms for different shapes. The algorithms are a bit self inventions, but a good method I want to mention is that get the histogram and then use projection on different axis helped a lot.
I'm working on a project in C# using XNA. It would be useful to have a way to graph the value of certain variables in real time as the game is running. (Just for debugging, I don't want the graphs in the final project.)
This seems like something that has probably been done before, but I can't find anything other than this:
http://devmag.org.za/2011/02/09/using-graphs-to-debug-physics-ai-and-animation-effectively/
I'm willing to write my own system or use someone else's. If there is an existing released project, I'd like to find it so I don't have to reinvent the wheel. If not, what;s the best way to handle this?
Thanks!
You could probably write a pretty easy system using XNA.
You should have something very basic for plotting lines:
public void DrawLine(Point first, Point second);
Run this system on every frame to collect the variable's value. Keep track of previous value.
Draw a line between previous value to current value.
If the sampling frequency is high enough, you can get a pretty decent looking graph like this.
You could write the values you want to check in a csv file, then draw a graph with excel. Here's a tutorial on writing a csv file writer/parser in C#.
The XNA hasn't support for drawing single line/pixels to screen directly (need to pass through a SpriteBatch). The only thing else I can imagine of is using a texture2D and draw your graph's pixels on it. You'll have to keep the texture in front of the camera though, with some strange matrix magics of which I don't actually know much. :P
The Xen graphics API has this feature. It appears to be for some built in variables, such as FPS, but it's all open source so I suspect it will be easy to add graphs of your own: http://xen.codeplex.com/
EDIT
I just remembered that Farseer physics also has code to do this http://farseerphysics.codeplex.com/. It's probably easier to rip out than the Xen graphs.
I am going to make a game like XNA example game "Platformer1" which comes with the XNA. But I need longer levels which doesn't fit in the screen (like Super Mario levels). How can I manage this kind of level? Do I need to use a 2d camera that follows the sprite? If I do this way how can I load the level? I am a bit confused and I am not sure if I could explain my problem clearly. Hope someone can help?
The tutorial based on Platformer Starter Kit in MSDN has a step Adding a Scrolling Level which guides you through creation of longer levels. The tutorial is very detailed, I highly recommend it.
I couldn't find the tutorial in the section for XNA Game Studio 4.0, but differences should be minimal. According to the comment at the bottom of the page, all you need to change is replace
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None, cameraTransform);
with
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullCounterClockwise, null, cameraTransform);
in the tutorial code.
If you want to create a side scrolling game, then I would look into parallax scrolling. A quick google/bing will help you find lots of tutorials. Also, another useful tip is to search YouTube for XNA videos has we a lot of posters share their source code .
Here is a link to Microsofts Parallax Scrolling.
Sounds like you have a few problems ahead of you.
But I need longer levels which doest'n fit in the screen(like super mario levels). How can I manage this kind of levels.
There are several ways to do this, but a fairly easy way would be to have a 2d array (or sparse array, depending on how large your levels are) of a class named Tile that stores info about the tile image, animation, ...whatever.
Yes, you'll probably want a "camera". This can be as simple as only drawing a certain range of that array or a more featured camera that uses transforms to zoom out and translate across your level.
Hopefully this will help get you started.
I've done a decent amount of work in XNA, and from my experience, there are 2 ways to draw a 2D scene:
1) Strictly 2D. This method is much easier, but has a few limitations. There is no "camera" per se, what you do is move everything underneath the fixed 2D "camera". I say "camera" in quotes because the camera is fixed (as far as I know). The upside is that it's easy, the downside is that you can't easily zoom in or out or do other camera effects.
2) 2D in 3D. Set up a 3D world with a 2D plane. This is more flexible, but is also more challenging to work with because you will need to set up a 3D world and 3D camera. If this is your first attempt with making a game, I would highly recommend against this method.
I'm really only familiar with the strictly 2D method, and you would want a list of map objects that have a 2D coordinate. You would also want to store which section of the map you are looking at, I do this with a Rectangle or Vector2 that stores this. This value would move forward as the character moves. You can then take your 2D map objects' coordinate and subtract the (X,Y) of the top-left of what you are looking at to determine an object's screen position. So:
float screenX = myMapObject.X - focusPoint.X;
float screenY = myMapObject.Y - focusPoint.Y;
An other thing to note, use floats or Vector2/3 to store locations, you may not think it's required now, but it will be down the line.
It might be overkill, but my SF project uses XNA to draw a Strictly 2D scene that you can move around: http://sourceforge.net/projects/asteroidoutpost/
I hope this helps.
Have a look at Nick Gravelyns tutorials. They helped me tonne when I was first starting out - Really really worth a look for learning a lot on 2D games.
All the videos are now on youtube here
I'm looking for a C# implementation of a Spline,
not to draw it, but to traverse it.
Basically I have a 2D game and I want an object to move on a predefined path.
Any ideas how to implement this ?
Thanks,
SW
Have a look at some equations on how to interpolate splines:
http://en.wikipedia.org/wiki/Spline_interpolation
This may also help: Calculate a bezier spline to get from point to point
When I had to do this for a game years ago, I implemented a form of parametric spline curve that was simple to build and required little in the way of CPU resources. What I built is similar to what's in the linked article. One really nice thing about this type of spline is that the math is not at all advanced.
Unfortunately, I don't have access to the C source code for my implementation.
Also check out Numerical Recipes, and netlib.org.