Jump to content

  • Log In with Google      Sign In   
  • Create Account


laztrezort

Member Since 20 May 2009
Offline Last Active Jan 23 2014 11:26 PM
-----

#4972882 Need Help Making a map

Posted by laztrezort on 23 August 2012 - 10:20 PM

To add to what SOTL said:

I had success years ago using a tile map editor called Mappy http://www.tilemap.co.uk/mappy.php with Allegro - there is even a "playback" library you can download that has a minimal tile engine built in.

Note that this was years ago, so I'm not sure which version of Allegro it works directly with, so YMMV.


#4969740 Debugging (managed) DX11

Posted by laztrezort on 14 August 2012 - 11:28 PM

With the DX debug mode enabled, are you still seeing debug output in the output console? what do the exceptions look like that you're receiving?


The only information it gives it an "HRESULT" value, "DXGI_ERROR_INVALID_CALL: Message Unknown", the rest of the exception data is default or unset. Output also gives no information. I get the stack trace up to the first managed call that produced the exception, of course.

Thanks Mike & JWalsh, I'll try these out and see what I can make work.


#4967206 XNA Standalone executable or installer?

Posted by laztrezort on 07 August 2012 - 06:47 PM

So in other words you need the XNA 4.0 framework to run a program created in XNA?


Yes. Here is a rundown of methods to distribute an XNA application: http://rbwhitaker.wi...-game-tutorials

Using ClickOnce (the fourth tutorial) is probably the easiest way to distribute an XNA game.

Edit: to clarify, using ClickOnce will ensure that the end user has the necessary XNA libs and .NET libs, and downloading them if they do not.


#4966822 NPC dialogues : file or script?

Posted by laztrezort on 06 August 2012 - 03:25 PM

I would like to see an example in which writing a script is required (in lua for example), because I didn't found anything on the web..Most of examples I've read are writable in a simple XML format file! So when is suggested using scripting language? Ok, when the behaviour isn't static like NPC dialogue, but I can't figure that kind of situation!


You could store flags and/or condition keys with the XML file, so that certain dialog node is only produced if the attached flag/condition is true. You can also store "magic" attributes to do hardcoded actions, such as "Open Store" or "Give Key to Dungeon". You can insert special embedded strings into the dialog to control things such as "Pause Here" or "Ask for yes/no".

At some point, however, you will realize that you are basically re-inventing a scripting language, as the list of attributes and magic keys and embedded codes grows. Animations, taking player items, healing the player, etc. You may find that your design has become brittle, in that you now have to go back to the source code to change & add dialog logic, do a full re-compile etc to test.

At his point, it may be worth looking into leveraging full scripting, where all of the dialog logic is isolated into seperate scripts. These scripts can be modified (sometimes during runtime!) during testing & debugging without having to change the main source code.

The tradeoff is the complexity of adding the scripting support, which isn't exactly trivial.

If you haven't already, plan out exactly what the extant of and logic of your dialog will be. From your OP, if that is the extent of your dialog system, then it looks like you can just implement [Condition Flag][Dialog Node] nodes in a data file and call it day.


#4965540 What engine would be good to make 2d games?

Posted by laztrezort on 02 August 2012 - 08:51 AM

Unfortunately, this question can really only be answered by you, since it depends on many things, such as your comfort level and available time for learning programming, specific goals, type of 2d games you are interested in developing, etc.

However, to clarifty one point, you can definitely make 2d games in Unity - in fact, there is an entire tutorial available on their site for making a 2d platformer. My suggestion is run through that tutorial and see what you think.


#4965534 2d lighting

Posted by laztrezort on 02 August 2012 - 08:41 AM

There a couple XNA libraries for dynamic lighting/shadows, one is Krypton http://krypton.codeplex.com/ I only know of its existance, I've never personally used it.

Here is an article describing one technique: http://www.gamedev.n...t-shadows-r2032

Here's another technique using XNA and shaders: http://www.catalinzi...mic-2d-shadows/

I thought there used to be another good article on 2d lighting on this site, it was a bit older but may have been useful, unfortunately I can't seem to find it.


#4965515 Need help in continuing

Posted by laztrezort on 02 August 2012 - 07:20 AM

1 - Can anyone explain or link, genericaly, how side scrolling works in terms of programing (or more specificaly in XNA)?


Assuming you are using a tile map (or similar), you just have to draw the correct range of tiles at the correct offset according to the current "camera" position. There are various approaches to this, one is to draw the tile map to a rendertarget, but drawing an extra column, then draw that rendertarget to the screen on an offset. The best way to work this out is to draw it out on graph paper first. I don't know of any links offhand, perhaps searching for "smooth scrolling tile map" or similar may net you some good info.

2 - My Tetris game had around 10 classes, (representing the state manager, the generic state, menu state, game state, paused state, and the game classes, block, map, piece (the block is each square) and the current moving piece), all this to a simple tetris. Now, Do a big game really has a huge ammount of classes? Like some for each level? Or am I thinking of it wrong?


You shouldn't expect to get a perfect design at first. That is what refactoring is for. My method is to just plug away at getting something to work, then I factor out base classes & interfaces when it seems applicable. Experience will certainly cut down on the amount of this type of refactoring, but I doubt it can ever eliminate it.

My code often contains many classes, it helps seperate functionality. However, you should look for ways where composition is more useful - for example, I've never made seperate classes for each level of a game, since levels are expressed as data, not polymorphism.

3 - All of the games Ive made untill now had colision or movment based on a grid (the pacman movment was fluid, but could only change direction on intersections), so , being 2D or even 3D, how am I supposed to check for colision between lots of diferent corpses? I know it is easy for spheres, as I can go through each object and check arround the radius, but what about more complex shapes like a sprite with a transparency in 2D or a person model in 3D? Does XNA has anything to help in this situation?


Collision detection covers a wide range of algorithms and methods, but it is well understood and documented. I'll try and throw some search terms out that you can research if you want.

Likely the most common method are bounding boxes, more specifically AABBs (axis aligned bounding boxes). The only thing that XNA provides that might be useful for those is the Rect class.

AABBs are usually good enough (and simple to implement), but if not there are other shapes (such as capsules), and even "pixel perfect" collision detection.

For checking lots of objects, modern hardware can actually handle a lot of checks. However, when it gets to be too much, you need to start optimizing. This is where broad phase and narrow phase checks come into play. Basically this means that you can eliminate many checks right off that bat.

As objects start to move quickly, it gets a bit more complicated ;). Since checks are only done every 60th (or whatever) of a second, fast moving objects can sometimes go through other objects before a collision check is made. I believe this often referred to as "tunneling". There are a whole slew of methods to address this issue, some of them get pretty advanced in terms of maths.

Note that we still haven't said anything about collision response, just in answering the question of whether to objects are colliding (intersecting). They may be touching, or one may be inside another, or (going back to the previous paragraph) we may have determined that they passed through each other in the last frame. How we want to resolve the collision is a different matter. Here is where physics libraries come in handy, which is what I usually fall back on as this stuff is mostly over my head.


#4965206 The code design of a game (C#)

Posted by laztrezort on 01 August 2012 - 07:57 AM

2. Im trying to learn somewhat off terraria's source but its really messy and doesnt use things such as inheritance. Please recommend any well designed games that has its source available to learn off (C# would be nice).


If you are using XNA, I would look through some of these: http://create.msdn.com/en-US/education/starterkits/, and poke around for other code examples on that site. There are many examples, they have been designed by some smart people, and they even include comments Posted Image


#4964950 Accessing the dd surface directly in xna?

Posted by laztrezort on 31 July 2012 - 12:48 PM

I could be wrong, but I would rather not iterate through a nested loop to render each tile as the screen scrolls. I've looked at several xna tile engines that use that sort of algorithm and I can't help but think it's not optimal. I would much rather pre-render the entire map in memory and then blit the window to the screen as it scrolls around.


Unless there are other considerations I don't know of, I can guarantee that such an approach will be fast enough (as long as you are not iterating far beyond the extents of the screen). I can also almost guarantee this approach will be far easier to implement than what you are describing as an alternative. I am also 80% sure that just iterating through and drawing all the tiles will actually be quicker than creating some sort of memcpy routine.

In short, SpriteBatch can throw many, many, many sprites onto the screen without a hiccup, unless you are doing something incorrect. If you haven't already, try out a quick prototype, you may be suprised.

If for some reason you do want to pre-render the entire map, just use a rendertarget to do so (you will need to stay within the limits of the graphics card constraints for texture size, however).

If you really, really want to implement a way to transfer data to a texture (not recommended!), then look at Texture2D.SetData and GetData methods.


#4964843 SDL.NET

Posted by laztrezort on 31 July 2012 - 07:02 AM

something like SDL.NET is far more exciting because nothing is done for you


It's been a long while since I've used SDL (and never the .net wrapper), but I don't remember it being particular "close to the metal" anyway. If you really want to dig into the inner workings of these systems, you will have to interface OpenGL or DirectX.

There are also some thin wrappers around DirectX and OpenGL you could use, some I've heard of (but never used) are SlimDX, SharpDX and OpenTK. I believe there is a book on using C# with OpenGL, but I do not know the name of it offhand.

Also, XNA is just a framework around DirectX, you don't have to use (for example) the provided Game class, or SpriteBatch, or BasicEffect. In fact, I'd wager many developers end up rolling their own versions of these classes specific to their needs anyway.


#4963741 Voxel Based Water

Posted by laztrezort on 27 July 2012 - 01:43 PM

Just spitballing a few things here:

A quick glance over the OP it looks like you are basically using a type of cellular automata, if that is the case then you could read this for some ideas: http://www.gamasutra..._automation.php

For optimizing, you will need to restrict the number of calculations that need to be made, there is really no other choice. This can be done by constraining the simulation to only those areas that need it and/or precalculating as much as possible.

I'm reaching on this one, but it also may be possible to memoize fluid calculations somehow (see here for example: http://en.wikipedia.org/wiki/Hashlife). If even applicable, this could greatly increase simulation speed (at the cost of memory obviously).

For determining feasability, the only way is probably to just bite the bullet and prototype the simulation.


#4963317 Passing this as a ref.

Posted by laztrezort on 26 July 2012 - 08:45 AM

I may be missing something obvious here, but I still don't see the need for "ref" here. The code would work as intended without ref, wouldn't it?

If the the OP is using or extending an API, then possibly it would make sense to me, although a bit odd.

For my part, I am unsure of the OP's famiarity with C#, so my first intuition was that there was some confusion about ref paramters vs. pass by reference. I know coming from C++ this was a point of confusion for me.


#4963281 Better procedural name generation

Posted by laztrezort on 26 July 2012 - 07:01 AM

Heh, happened to come across this article http://thedailywtf.c...-Generator.aspx, a cautionary tale perhaps? Posted Image


#4963066 Preventing Chaos in your game code

Posted by laztrezort on 25 July 2012 - 03:12 PM

I usually refactor when I see one of the following:

1 - I have the same code in mutliple places - a good sign that the common functionality needs to be refactored out into its own method or object
2 - I have a largish glob of complex or hard to read code - a good sign that I should seperate the logic into multiple methods/classes.
3 - I keep having to tack on extra checks or variables to handle corner-cases, or the code is beginning to feel "hackish" - this is usually a sign that I need to rethink my design on a higher level.

I don't necessarily see any of this in your posted code, although these rules are somewhat subjective anyway. There may be idiomatic C++ concerns as well that I am not qualified to comment on.

As the complexity grows, you may find that you want to isolate your input handling code, or message dispatch, etc. Personally I try and avoid long if-else-else-else... chains if possible, they tend to confuse me when revisiting code later, YMMV.

An easy trap (for me, anyway) to fall into is to try overengineering too early - I may feel clever with the results at first, but later humbled when I find that I need my design to go a completely different direction anyway.


#4960621 passing a value from one class to another

Posted by laztrezort on 18 July 2012 - 01:48 PM

the problem is that after the enemy die, EnemyKilled variable keep going up. it should be equal to 1 when enemy die, but it goes 1, 2, 3, 10000 etc ...


I have a feeling the answer is hidden right there. What is happening to make the killed counter keep increasing? When shouldn't the counter increase? Is there something else that can be checked, in addition to the collision itself, before increasing the counter?

This is what I think you are looking to do (spoiler tags in case you want to try and work through it yourself first):
Spoiler





PARTNERS