Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

VildNinja

Member Since 06 Mar 2008
Offline Last Active May 19 2013 04:50 AM
-----

#5011826 Tutorials sought

Posted by VildNinja on 17 December 2012 - 03:37 PM

Sounds like you ought to step away from video tutorials, and start reading some :) While they may not be less explanatory, it is way easier for you to skip ahead, once you understand the topic.

Based on my own experience these are good points of entry:
http://lwjgl.org/ Best OpenGL wrapper for Java (I should probarbly not call it the best, since there are a lot of different opinions on this topic, but it is the most used wrapper for comercial use).
http://nehe.gamedev.net/ OpenGL Most of their guides have LWJGL code as well. Otherwise OpenGL is OpenGL regardless of Java or not.
http://www.cokeandcode.com/ A great blog! also the home of the Slick library

Also remember that c++ is not the necessarily the next step. It is some thing that is good to learn at some point, but you can make great games with Java, without knowing any c++.


#5010798 Threads + Concurrency & Weird Issue

Posted by VildNinja on 14 December 2012 - 06:49 PM

Could you provide some code?

Also it almost sounds as if you are creating a thread for each event? And using another thread to activate them? Threads aren't some thing you should create a lot of. They will mostly just give you trouble. If you want to add timed events you should either only have one thread doing it, or even better, add a priority queue in your game loop and perform and remove/reinsert the event at the top of the queue if its time has expired.

But any ways post your code, then I'll take a look at it tomorrow :)


#4985981 Adice for my game project prototype?

Posted by VildNinja on 02 October 2012 - 01:37 AM

That is a lot of questions. rather than answering them all, I'll tell you how I would approach this type of game.
  • You need a grid. I would not place the tiles manually, since that would make it difficult to determine which tiles are connected to which. I would start out with a 2D array of Tile, where Tile is an enum of tile types:
    Edit: aparently <= breaks the code block. So I use (less or equal)..

    [source lang="csharp"]public enum Tile {DIRT, ROCK, WATER, BOMB}; public GameObject dirtPrefab; public GameObject rockPrefab; public GameObject waterPrefab; public GameObject bombPrefab; Tile[][] map = { { DIRT, DIRT, ROCK, DIRT, DIRT }, { DIRT, DIRT, ROCK, DIRT, DIRT }, { DIRT, WATER, BOMB, WATER, DIRT }, { DIRT, DIRT, BOMB, DIRT, DIRT }, { DIRT, WATER, BOMB, WATER, DIRT }, { DIRT, DIRT, ROCK, DIRT, DIRT }, { DIRT, DIRT, ROCK, DIRT, DIRT } } int bombLocations = 3; int bombsToBePlaced = 1; void Start() {   for (int x = 0; x < map.Length; x++) { for (int y = 0; y < map[x].Length; y++) {   switch (map[x][y]) {   case Tile.DIRT: Instantiate(dirtPrefab, new Vector3(x, 0, y), Quarternion.identity); break;   case Tile.ROCK: Instantiate(rockPrefab, new Vector3(x, 0, y), Quarternion.identity); break;   case Tile.WATER: Instantiate(waterPrefab, new Vector3(x, 0, y), Quarternion.identity); break;   case Tile.BOMB: if (Random.Range(0.001f, bombLocations) (less or equal) bombsToBePlaced) {   Instantiate(bombPrefab, new Vector3(x, 0, y), Quarternion.identity);   bombsToBePlaced--; } else {   Instantiate(dirtPrefab, new Vector3(x, 0, y), Quarternion.identity); } bombLocations--; break;   } }   } } [/source]
  • In the editor you should create a Prefab for each tile type you want, and add them to into the script. The prefabs should be no more than 1x1 in x and z. Now you'll get a map where one bomb is randomly placed on one of the three bomb locations.
  • Next step is to be able to click a tile. Since your tiles are axis aligned on x and z in y = 0, you can easily where the player clicks in your grid:

    [source lang="csharp"]if (Input.GetMouseButtonDown(0)) { Vector3 pos = Camera.main.transform.position; Vector3 dir = Camera.main.ScreenToWorldPoint( new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1)) - pos; float scale = pos.y / dir.y; Vector3 point = pos - dir * scale; int x = Mathf.RoundToInt(point.x); int y = Mathf.RoundToInt(point.z); print("x: " + x + " y: " + y); }   [/source]
  • To import the 3D model you should drag it to the scene, create it as a prefab, scale it to the desired size, apply and remove it from the scene, and finally instanciate it from a script.
  • I don't have time to talk about movement now, but I think this should be enough to get you started Posted Image
Edit: split up source block, since it didn't show entire code


#4985717 Adice for my game project prototype?

Posted by VildNinja on 01 October 2012 - 05:29 AM




So i need to make a grid kindof like chess has.

you should use a 2D array for that.


What do you mean?

...
If you make your grid as one big tile with a grid texture (or if you're merging tiles) you can still use the raycast to get the point on the grid that was clicked on and then divide that by your tile width and height to get the tiles position in a 2D array.

Yes that is the approach I would use. That way you can always decide to remove the texture from the big grid, and add your own cubes or tiles as a graphical overlay. But use the single simple plane to maintain the relation between your 2D array and world/input space.

I dont get option to rename scene or script files inside from unity projects view.

Yes you do. If you click the name twice you can rename it.

True.. this is good advice but is it really so much more work to make many planes next to eachother? isnt it possible in some kind of loop?
I dont know yet how big playing field i want or how big each tile should be... that is another thig i must test in this prototype.. so it must be easy to edit how big map and how big tiles.

Yes you can easily write two loops that can instantiate a number of tiles in the scene.
[source lang="csharp"]int width = 10;int height = 10;Tile[][] tiles = new Tile[width][height];for (int x = 0; x < width; x++) {  for (int y = 0; y < height; y++) {    Instantiate(tilePrefab, new Vector3(x, 0, y), Quarternion.identity);  }}[/source]

I don't really understand your directions.. sorry
I know what variable and reference is but I don't understand... if I am standing on a tile how can i click somewhere so it moves to a nother tile? so if i click somewhere that the game can see i clicked within a grid tile (how can i make a grid? i have board to looks like a grid but its just texture that code doesnt know is a grid?

Get a ray from the camera towards the mouse position. Get the x and z coordinates where y hits zero, and cast x and z to integers and plot them into your array (tiles[x][z]). If your characters should walk around like humans, you'll probably need some path finding (A*). If your characters move around like chess pieces you should just use slerp or lerp to move them between the two tiles with a coroutine.


#4985479 Adice for my game project prototype?

Posted by VildNinja on 30 September 2012 - 02:34 PM

I have very advanced complex combat system that is too much complex to have on just paper.
I need to prototype it.

Start of with something you can put on paper. Once you got that working you can think about how to make your idea fit on paper. If you really can't I would suggest you to redesign your idea.

So i need to make a grid kindof like chess has.

you should use a 2D array for that.

IM USING UNITY! and will use c#.

I want it to be in 3d too with isometric or 3rd person camera.

Well first step is to make it top down with no perspective. The difference between that and isometric 3D is one matrix a checkbox and moving the camera. So I see no reason why you should bother with that before you got your grid working.

But I need help with how i will make the play field.

So how do i make this tile based grid? (guessing its coreect lingo.)

You shold take the simple soloution and use ONE plane with ONE texture on top of it. This can be limiting if you want randomized maps or animated tiles. But for now you should just make the game work with one static image.

I want each tile to be seen graphically too.

So i need to have a texture for what each tile looks like with a nice border.
then I import the texture to unity and assign it to material.

then i create a plane that i assign this material for.

Then I will have 1 tile so far.

You got plenty of coding to do right now, so don't bother with this quite yet. You'll have plenty of time fiddleling with the right approach later on, but don't waste time on this now.
Edit: your ONE texture should contain several tiles.

Now what's the best way to create a 3d board tile based grid?

maybe its better to not use plan but instead  cube?

Cube or plane really dosn't matter! The best way to create a 3D grid, is to calculate the mapping between mouse clicks and coordinates in your array. Whether you use planes or boxes or teapots for each tile should not be relevant to your logical grid.

ok..
So i want to be able to move my characters from one tile to another by either being able to click on a tile and it moves there or by for example using arrow keys to move one tile ahead.

use on variable to hold a refrence to the selected character. If the variable is empty/null assign it with the next clicked character. Else move the characters logical position to the desired tile, and use a coroutine to animate the movement (with slerp or something).

also, the game i want to make should be multiplayer.
but im newbie at networking.

so i think for the prototype i will just make enemy npc controlled with simple AI?

Figure out a way two people can play the game on one computer. You can always play with AI, but AI is NOT simple! At least not if your game concept can't be written on paper ;)

Also, in unity..
If i have given a name to a file on projects tab like for example a scripts file or a scene file a name..
Is there an easy way to rename it later? because the codes and everything that uses that file will then have the old file name?

Yes Unity takes care of the file name - don't change it from explorer - and Mono Develop or Visual Studio have ways of automatically renaming variables and classes. I think it's on F2 - otherwise just right clcik the variable or class name you want to change, and select rename/refactor in the menu.

Big time thanks to everyone who reply.
This is the best forum.

Hope this is usefull


#4976401 Help me design an MMO-ish turn-based strategy

Posted by VildNinja on 04 September 2012 - 07:01 AM

You keep using that word MMO, but I'm not sure you know what it means.

The simplest solution I can think of, is to make the networking entirely http based. That way you can code the account system in php connected to a MySQL db or whatever server side language you prefer. And for a turn based muiltiplayer game with no more than 32 players at a time, you could just as well code the game logic in php.

That way every player just needs to connect to the server every second to check for updates.

Your updates could contain some json or xml with info on the recent moves/actions and maybe the entire game state, just to verify the synchronization. The update should also let everyone know whose turn it is.

This is no an optimized approach, since every player connects to the server even if there are no new updates. You could write the server using simple tcp sockets for better performance, but I don't think you'll gain anything from that on a 32 players tbs. Any ways code the account/login system in php or other server side language.

Hope this helps :)


#4976219 How can I train myself to come up with simpler ideas?

Posted by VildNinja on 03 September 2012 - 04:15 PM

When we teach at game development workshops for high school classes we always teach them not to make a game. One of our most used (and useful) guidelines is to make a toy not a game. In other words think of a single game mechanic you like, test it, and if it is fun make a game out of it. That way you ensure to always start with something fun, and then you can add story line and other elements afterwards. Preferably as an iterative process.


You are not alone on this, this is much more common disease than you think Posted Image I think there could be several cures, the one that worked out for me was a deadline. When I set up a deadline (very short one) and actually completed a game the first time

Yes! And the best place to do that imho is at a game jam! Seriously DO IT you don't have to go to a physical one, there are plenty online.

Edit: This technique is probably not well suited for larger game projects, but it is a great training exercise if you want to make simple games.
Edit2: Examples: Gravity gun, Portals, Bullet time, etc.


#4945153 C#/XNA or Python/Pygame for Game Development (2D Side-Scrolling like Terraria)?

Posted by VildNinja on 31 May 2012 - 07:18 PM

If you are serious about it you are most likely going to learn all of the above at some point in the future (maybe not VB). The important thing right now is that you learn one language and learn to make a game with it. If you know one language good (rather than knowing five poorly) it's easier to learn other languages later on.

Python is a good language so I see no reason why you should learn Java or C++ right now, if you would rather use Python. You can either use PyGame or Pyglet if you want faster graphics (I used Pyglet for two Pyweek games.. I like it). I don't know any good tutorials, but I'm pretty sure google can help you with that :)

If you insist on choosing between Java and C++ I would suggest Java since it has a lot of usefull libraries and great documentation. But don't rush towards Android before you have made a few games for pc first (the debugging process is rather cumbersome).


#4941757 box2d concave interior question

Posted by VildNinja on 20 May 2012 - 05:06 PM

You can add multiple fixtures to a body. You should add three. For each fixture you should add a box shape and position the shape relative to the center i.e. (0,1) for roof, (1,0) for wall, and (0,-1) for floor.

Hope this helps :)


#4940032 Java Tutor.

Posted by VildNinja on 14 May 2012 - 05:56 AM

http://lmgtfy.com/?q=java+game+tutorials

Bonus: Two ways to draw in Java, that I have used with great success :)

For software graphics (like flash before v11) you should read this article http://www.gamedev.net/page/resources/_/technical/general-programming/java-games-active-rendering-r2418
The advantage by using non hardware accelerated graphics is that it's easier to use in an applet, if you want your game to be playable from a browser.

If you want hardware accelerated 2D graphics this is a great library: http://slick.cokeandcode.com/


#4935812 Mixing reliable and unreliable messages

Posted by VildNinja on 29 April 2012 - 06:53 AM

Hi, I'm currently working on pretty much the same thing :)

my approach is to have the first 16 bytes in each package as a header, consisting of four integers.
0 = hash tag to sign the package (hash of package content + shared session key)
4 = package confirm (the last received package from the connected peer)
8 = package id where value 0 - 9 are reserved (0 => unreliable)
12 = session id

In short:
If I receive a package with package id = 0 I'll verify the content of the package, copy the confirm value to my outbox (so i know which packages not to resend), and finally pass the remaining data on to the user.
If I receive a reliable package (package id > 9) I'll do the above steps, and set a flag to confirm the last received package. On the next send call I'll set the confirm value in all outgoing messages to latest received package and send them. If my outbox is empty I'll send an unreliable package to confirm.

To answer your questions:
1 )
Since you are using UDP you might as well use the power of UDP - besides easy NAT punch through, so I would not recommend you to send everything reliable.
2 )
If you want the unreliable packages to be fast you should not bundle them with reliable ones. Unless you are going to send an reliable package at the same time. Then you might as well bundle them (but not necessarily the second time you send the reliable package (if first try should fail)).
Yes you should defiantly acknowledge reliable packages in your unreliable packages.  
Knowing nothing of your game, and not being that experienced in networking I don't know the answer for the last question in (2)
3 )
The answer for this is pretty much the same as for (2). I don't - I neither deals with payloads, but only packages.

Hope this helps :)


#4882595 Is Unity3D spoiling me?

Posted by VildNinja on 10 November 2011 - 08:39 AM

You would probably be surprised of how many professional teams are using Unity for their commercial projects. So no you are not spoiling yourself by using Unity. I would however say (based on experience) that you are spoiling yourself/Unity by using Java Script in Unity. You are both missing out on some cool features such as generic lists you can access directly from the Unity editor and enums you can access as drop down boxes in the editor. Plus the auto completion in mono develop doesn't work that well with Java Script, while it works super with C#. Finally Java Script in Unity hides away some of the code, which makes it a lot harder to understand the core principles behind object oriented programming.

So keep using Unity, but switch to C# now! If you in two years still haven't tried anything but Unity, then yes you are spoiling yourself :)


#4868878 HTML5

Posted by VildNinja on 04 October 2011 - 01:29 AM

Does anyone know where I can find a good beginners HTML5 tutorial. Not one that only explains the new features of HTML5, but one that teaches everything?


http://diveintohtml5.org

I haven't read it myself, but got it recommended a year back by some IT journalist.

Edit: The site looks to be down, but the book can be found here http://www.jesusda.com/docs/ebooks/ebook_manual_en_dive-into-html5.pdf or on google


#4863633 FPS position update packets come through in bulk.

Posted by VildNinja on 19 September 2011 - 07:26 PM

Some network APIs don't send the data right away, if you're only sending very small packages. Instead it buffers them until the package has a decent size. This is done to minimize the overhead of each package. To avoid this, you should be able to either tell the network API not to do that, or you can flush the connection. I can't say exactly how you should do this without knowing what language you are using.

BUT as you mentioned yourself: you're supposed to work around it :) even if you send the packages one at a time, latency can still make your game appear jumpy in no time :( Instead you should simulate/predict what the user is doing. Instead of sending each update, you should only send each player action. When the player starts moving forward, send a message to the server, that the player is mowing forward, and let each client simulate the entire movement, until the player stops moving forward. This should keep all clients in sync, and allow for smooth movement.
You ought to correct the player position once in a while as well, in order to avoid a minor difference on the server and a client, means the difference between bouncing into a wall, or not. This can be done with every player action update.


#4837604 [java] java internal java.lang.ArrayIndexOutOfBoundsException

Posted by VildNinja on 19 July 2011 - 02:25 PM

Yes swing does it behind your back.. does it happen at random, when you click some thing, or does it just happen at random?


Do your program use any kind of text verification?
Do you have a game loop, that repeats some code?
Do you do any thing in the thread that opens the window (calls setVisible) after you've opened the window?

Edit: if yes, please post the code :)




PARTNERS