Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 28 Jun 2000
Offline Last Active Today, 05:38 PM

#5226718 Interested in creating new game engine for a space adventure game; questions...

Posted by Wyrframe on 01 May 2015 - 10:28 AM

Sounds like someone just found out about the cancellation of 0x10c.


In case you are serious, dopefiend (which is a stretch)... start small. Make your first-person game in a level, then make that level into a ship, then make that ship fly, then make the consoles and machines in that ship interactive, then make them driven by some kind of virtual computer instead of a fixed set of game-driven screens and systems. There's no way you can make the entire monolithic thing in a single go, no matter how new or experienced a developer you are.

#5226394 Rendering Perspective Text

Posted by Wyrframe on 29 April 2015 - 06:48 PM

Why not transform just the "anchor" point of the text (usually the bottom-center of a line, or the top-left of the leftmost character, or something) to get a screen-space position for the text, and then draw your glyph-sprites relative to that position using Spritebatch. Round to the nearest pixel after calculating the screen-space position to reduce aliasing effects.


Unless you need your text to have size and rotation appropriate for billboarded objects in-world? Then create a billboard transformation matrix appropriate to the anchor of your text, and then just lay out your glyphs within that single billboard model space.


I'm not sure what you're asking for with "perspective text", nor why you think it's too much work to transform individual glyphs before passing them to Spritebatch. It sounds like a necessary step to get any individual sprites into the scene.

#5224322 Playing ogg file with openal and stb_vorbis?

Posted by Wyrframe on 19 April 2015 - 10:26 AM

Try using stb_vorbis_open_filename() instead; that returns an stb_vorbis*, which you can pass to stb_vorbis_get_info() to get an stb_vorbis_info struct; that will tell you the number of channels and the sample rate, which you then multiply together with stb_vorbis_stream_length_in_samples() to get the total file-in-memory size you will have when you've read the entire file, if you want to have the entire file in memory at once.


Then, you can pull the audio data progressively into memory as you need it, using the stb_vorbis_get_frame[...] or stb_vorbis_get_samples[...] families of functions.



Edit: just looked at the stb_vorbis_decode_filename function; it returns the number of samples decoded, and you told it the number of channels and the sample rate. Multiply those three together, and you get the total number of shorts in the buffer; multiply by sizeof(short), and voilá; size of that buffer in bytes.

#5222802 Programming fake 3d using sdl?

Posted by Wyrframe on 12 April 2015 - 02:13 PM

I'm fairly sure that in that particular instance, they've basically just rendered one 90° rotation animation and one "walk one tile forward" animation of the checkerboard, de-duplicated it into a tile map to save video memory, and are just playing those two animations with palette swapping to set the colours. And because will only need to have rendered the checkboard animation once, every time the player makes a full step forward, they swap the two colours of the checkboard palette so they can continue to use the same animation frames.


If you want the same basic effect on a more complex map (e.g. an arbitrary tilemap, instead of a featureless checkerboard), you're probably best off using a single-object raytrace-like projection. You can save CPU time and reduce rounding-error-induced aliasing by pre-calculating a projection of your viewport to the on-map coordinates to sample each pixel from (giving a lookup table of 2 floats per screen pixel), and then applying translation and rotation to those relative offsets from the camera. Use the inverse of that projection function to project sprite objects into camera space.


Do you have a specific reason for not wanting to use OpenGL? A self-imposed limitation to experiment with a technique is just fine, but if you're of the mind that OpenGL isn't worth learning to do this, you might want to reconsider.

#5221653 are non sql databases better than sql databases?

Posted by Wyrframe on 06 April 2015 - 11:13 AM

It sounds like you have a sever which has some game-like behaviour, and you need to get data to respond to a user's requests at least once every few seconds. You think you want Redis because it provides a caching mechanism as well as a persistence mechanism, which isn't a bad idea. What I'm getting from you so far is that you don't know what to use as a key, and you're worried about serialization/deserialization time for the objects you're storing as values in Redis. Correct me if that's wrong.



Let's take a step back. What is the data you want to store (as in, if you were going to make one or more C# classes that represented it, what properties and private fields would these classes have)? How do you want to be able to look this data up (as in, what would go in the WHERE ... clause if you were to search for this data in an SQL database)? And how often do you expect to be making such queries (don't forget the appropriate units; this is a # of queries per second per user, usually)?


If you can answer those, you'll start to develop a clearer idea of what your requirements are. There's nothing wrong with Redis AFAIK, so you just need to figure out how to use it with your dataset.

#5220501 Is my triangle intersection code correct?

Posted by Wyrframe on 31 March 2015 - 09:51 AM

IsitSharp: that's not an equation, it's a function definition. What you are to solve is this set of equations:
   Px( a, b ) - Rx( c ) = 0
   Py( a, b ) - Ry( c ) = 0
   Pz( a, b ) - Rz( c ) = 0
Which if I write ray.origin and ray.direction as r0, r1 respectively,

t3x + v1x * a + v2x * b - r0x - r1x * c = 0

(repeat for y, z in place of x)



Which I think gives you the matrix...

[[ v1x, v2x, -r1x ]    [[a],    [[r0x - t3x],
 [ v1y, v2y, -r1y ]  *  [b],  =  [r0y - t3y],
 [ v1z, v2z, -r1z ]]    [c]]     [r0z - t3z]]

(Edit: Haegarr pointed out the negations I forgot to include)


... but it's been seven years since I last did this by hand. I remember how frustrating it was when I first tried to figure this out. I used http://www.mathsisfun.com/algebra/systems-linear-equations-matrices.html as my reference just now.

#5218628 [JavaScript] Is there anything I need to know before making a browser game?

Posted by Wyrframe on 23 March 2015 - 04:11 PM

At the point you're at, start with a WAMP or LAMP server on your own PC (links and info about those in the GameDev forum thread you linked). Don't worry, it's not some arcane unique software, it's an acronym; (Win/Linux) + Apache, MySQL, PHP. Between those three pieces of software, it's a decent entry-level application runtime environment. If you're comfortable with any IDEs, such as Eclipse or FlashDevelop, take a look around for any PHP integration they have.


A bunch of random tips, in no particular order or grouping...


You're going to be developing on only your computer for quite a while, pointing your web browser at your own PC (http://localhost, etc). Don't go looking for any free PHP web hosting until you've got at least something playable and stable, and are ready to start sharing it with an anonymous audience. And be ready for it to get torn to shreds, both by commentary and security holes. Never put anything on that server you're not ready and willing to lose. (Edit; half this paragraph got chopped off somehow. Re-typed the gist of it.)



Despite my suggestions about PHP above, and despite it being often considered the "industry standard" entry level programming language, I don't personally recommend it. It's easy, but it's so, so dirty, covered in two decades now of amateur design principles and intractable security and text-encoding bugs. As someone who has been using PHP my entire professional career, and all the way back to 2001 before that... learn it so that you have the experience, but don't treat it as the be-all-end-all of web scripting. Learn Java+Tomcat, learn Ruby, learn a C++ CGI library. There's lots of design principles that are transcendant of language and library, and it's good practice to learn them in more than one medium.


As far as a MUD... learn what a state machine is and is not. You're going to be reading world and object state, validating a requested action upon it, making that change, and then writing any parts of the world that changed, every time a request comes in. Never assume that any data remains valid for longer than it takes to answer that request. Make sure you can save the entire database state at any time, and then restore to it later, because you will often have to take a snapshot, test an action, compare it against expected results, and then restore the database to a few seconds earlier just so you can try it again. Assume that anything you might do (restart the server, snapshot/restore database state, any given in-game action, etc) will happen ten thousand times a day. You can't do it manually. Write scripts, check error codes and messages.


Use version control; even a single keystroke gone wrong can turn a working application into one that doesn't anymore. Every time you have a working, stable version of your code, commit it, and then work on the next single actionable task. Never commit untested code, never go more than an hour without committing, and never, ever, leave the commit comment blank.

#5218281 [JavaScript] Is there anything I need to know before making a browser game?

Posted by Wyrframe on 22 March 2015 - 11:34 AM

First, a couple things about what you've said so far.


* JavaScript is its own distinct creature. Its syntax is shared with the rest of the ECMA Script family, but it has its foibles and quirks. Be aware of them. In particular, it handles up-values differently (and IMO, better) than other scripting languages I've worked with.


* To your 3) Player information is stored somehow on the server. At no point should you ever write anything in the client-side code that knows or assumes how or where the server gets that information. In fact, in early server prototypes, I often use flat files (folder per "table", filenames as per unique key) until I have the schema down pat.



There's a few important differences between browser and desktop programming, as far as program behaviour goes. The one that seems most obvious in retrospect but somehow still gets left by the wayside so often is that the server might become inaccessible at any time, and your program needs an escape route. Maybe not a recoverable one (exit game to main menu, give error message), or an unfrustrating one (UI dims and shows "synchronizing..." while the request is re-tried until it works), but a well-defined user experience escape route nevertheless.


If you're ever going to have your client-side scripts make requests to multiple servers, be aware of the HTTP OPTIONS request, and how in this modern day and age it is no longer optional. This will save you a lot of time and hair trying to figure out why your HTTP requests are just disappearing into a black hole, not coming back to your error/failure handler.


Anyone can view your source, so you should be sure to contain all the critical stuff on the server side, and when programming the server, always assume a hostile agent. Every POST must be validated against correct inputs, every player move must be checked for being possible given the current state of the game, et cetera. You can use "minify" tools to scrub your client-side code down in release builds, removing unnecessary whitespace and replacing variable names with meaningless tokens, but anyone can reverse this process. It's orders of magnitude easier than reversing the binary assembly produced by C/C++/etc compilers, because they still have the original structure of the code, even if they've lost the semantic labels.


And last of all, test in many browsers. I don't mean "IE, Firefox, Chrome, Opera"... I mean "Chrome, Firefox 478 (or whatever we're on now), Firefox 27, Firefox 14, IE 10, IE 9, and IE 7". You'd be amazed at some of the differences in functionality, document parsing, image loading, and DOM-manipulation bugs between even just minor versions of a given product (speaking from experience; the Windows 7 Service Pack 1 version of IE9 has different Compatibility Mode auto-detection results from the manually-downloaded-from-Microsoft-Website version of IE9, and therefore parses the JavaScript differently).

#5214997 CopyOnWriteArrayList

Posted by Wyrframe on 06 March 2015 - 01:04 PM

Are you using the for(var: collection) construct to iterate? That silently creates an Iterator, which throws ConcurrentModificationException if you modify the collection it is backed by.


If you are removing the element you are examining, such as below, then you should explicitly create an iterator and use its remove() method.

Iterator<Foo> iter = fooArrayList.iterator();
while( iter.hasNext() ) {
    Foo e = iter.next();

    if( e.isBar() ) {

Alternatively, simply build up a list of elements that must be removed, and then remove them one by one after you finish iterating through the list of elements.


Finally, if the elements are UI components in a Swing or AWT hierarchy, and you absolutely positively cannot be sure whether you are in an event handler or not while iterating on your collection, you can make sure you don't modify the view from inside the event handler thread by using the SwingUtilities.invokeLater() method.

for(Foo e: fooCollection) {
    if( e.isBar() ) {
        SwingUtilities.invokeLater(new Runnable() {
            void run() {

Disclaimer: I do not claim that any of the above suggestions meet best practices; only that they let you avoid modifying a collection while it is being iterated over.

#5214851 SpriteSheet Class won't correctly display transparent images

Posted by Wyrframe on 05 March 2015 - 05:23 PM

Knowing nothing about Pygame and almost as little about Python in general...


The method "image_at" seems to create a new surface, copy a sprite from the sheet to that surface, and then set the colorkey value for that surface to either the provided colour key or the value of the pixel at top-left of that single sprite. Is that all correct?


Does the created surface support colour keying? Does it support alpha? Does the blit method respect transparency? These are all things I'd start by verifying.


Also, if your PNG is already transparent, not all transparent pixels are equal unless you are using premultiplied alpha (which seems like something you'd have to explicitly invoke, unless that's a function of the .convert_alpha() method). Two pixels with alpha=0 can have different colour values, and that might be confusing your colorkey selection.

#5212345 Simple Geometry UV Mapping ?

Posted by Wyrframe on 22 February 2015 - 05:11 PM




#5209821 Does gpu guaranties order of execution?

Posted by Wyrframe on 10 February 2015 - 10:28 AM




#5209439 Voxel disk operations?

Posted by Wyrframe on 08 February 2015 - 11:20 AM

Minecraft doesn't save the meshes that the graphics client generates using the map-chunk data. Why should it, when it can re-generate it on demand, and in fact needs to every time the map-chunk is changed?


Generating a mesh from nice, clean data is trivial compared to serializing a mesh to and from disk.

#5032781 Question about Eclipse, JDK, JVM and JRE

Posted by Wyrframe on 15 February 2013 - 02:09 PM

Eclipse; an editor and build-management environment.


JVM: Java Virtual Machine: the program, implemented differently for different platforms, that runs the java bytecode created by the compiler.


JRE: Java Runtime Environment. Usually the Oracle or GNU implementation. Contains a JVM and the standard library implementation, but no editors or compilers. It's meant to provide a complete but only sufficient runtime environment.


JDK: Java Development Kit: the JRE, plus a compiler.

#5021936 Best practice needed for implementing an AI for a turn-based game

Posted by Wyrframe on 15 January 2013 - 03:34 PM

Your game state should be fairly simple to encapsulate; if it isn't, you should do that before you attempt any sort of AI. The complete representation of a board game's state should be a simple, relatively shallow object (ie. containing at most some arrays of basic data types) with a copy constructor.


For instance, a checkers game can at its simplest be represented with three 32-bit fields; the 8x4 valid board positions is 32 places, and the three fields store black's pieces, red's pieces, and kinged pieces. Your AI will need this "gamestate" object to evaluate options, and if your AI is recursive (some not-mutually-exclusive alternatives being strategy-based, heuristic-based, and table-based; but you can combine all four types easily) it will need to make at least one copy of this gamestate to recurse upon and evaluate its choices.