|
Simple 2D wireframe animation - pointer troubles
Hey all,
I recently started working on a very simple (and crude ) 2D wireframe engine, in c++, using djgpp & the allegro library. Now, seeing as I haven''t read any books yet, at all, my method of making games so far has been somewhat simplistic and far from speed conscious (and, to those of you who like it elegant, I apologize ). I''ve done a fair few games already, including a simple raycaster, so please, don''t treat me like a complete idiot in your reply . The only trouble is, i''ve never grasped those little things called pointers. Ah. Oh dear. The only slight problem is, I really think it''s about time I did... basically i''ll just give you some background on my current project & then present the problem. Basically, it might end up as a crap 2d fighter, but at the moment i''m working on the editor, in which I want to be able to save / load and then edit every frame of every animation, and play it through. Most of that is no problem. The method I am using to draw the player at any time is using a collection of vertices, which are defined in a simple struct (called vertex, would you believe ), each with an x and y int. Now, I have a struct called anim, which contains the number of these vertices needed to make up a body (its simple at the moment, about 30). I know which vertices to draw a line between (i''ve only hazed over the details here). That''s all no problem. In my player class, I have several arrays of anims. Think of a single anim as a frame, and an array as the full animation. Ok? Good. Now stop laughing at however stupid you may think that is, because its what i''ve settled with . Right, on we go. The problem (at last, I bet you''re thinking) comes when trying to decide which animation to draw at any one time. The current frame is no problem, because I can just index through the array of the current anim. The problem is, determining that current anim. Assuming I want a decent frame rate, using an index of the current anim in a variable and using a switch statement to determine every frame which is the current animation is hugely inefficient (not to metion long and ugly). I can''t help thinking that something like a pointer to an anim would solve all this... I simply draw / animate / edit the current anim just by using a pointer''d anim. Setting the current anim would just involve passing an index which i''d determine which animation to use from that, and drawing / animating would be the same code for any animation... right? Ok, i''ve messed up my explanation, so here''s what i mean... sorry I didn''t do this code box earlier, but I know the forum eats multiple source brackets, so I had to save it all for one...
Hmm, I think that gets the idea across... basically i''m just
confused / worried about syntax, the use of * or not, the use of -> or ., whether or not I need references (&) or not... all so very confusing . Anyway, sorry if i''ve waffled... this has taken me an embarrassingly long time to write (I had to simplify the context a bit) and I hope I eventually got the message across. If not, this has been a bit of a waste of time, but tell me and i''ll try and rephrase it .
Cheers all,
Nick - Head Designer, Llamasoft.net
--
Visit our website...
Llamasoft.net
Games, goodies and ingenuity
Nick - Head Designer, Llamasoft.net--Visit our website...Llamasoft.netGames, goodies and ingenuity
Damn, sorry about that, bloody thing isn't letting me edit that post (either BOF or EOF is true ... post.asp, line 105). Er, basically, that's not meant to be
but
stand< i >.v[j].x = whatever;
but
stand.v[j].x = whatever;<br> </pre> <br><br>(I had to leave a space there so it didn't think I meant italics, just in case <img src="wink.gif" width=15 height=15 align=middle>).<br>Ok, I think that's the only major mistake <img src="tongue.gif" width=15 height=15 align=middle>.<br>Cheers all, <br><br>Nick - Head Designer, Llamasoft.net<br><br>–<br>Visit our website…<br><br><A HREF="http://www.llamasoft.net" style="text-decoration: none;"><font color=#138DFF>L</font><font color=#3999FF>l</font><font color=#43A4FF>a</font><font color=#57AEFF>m</font><font color=#69B7FF>a</font><font color=#73BBFF>s</font><font color=#8BC7FF>o</font><font color=#95CCFF>f</font><font color=#A9D6FF>t</font><font color=#B7DCFF>.</font><font color=#C1E1FF>n</font><font color=#DDEFFF>e</font><font color=#FFFFFF>t</font></A><br>Games, goodies and ingenuity<br><br>Edited by - Llamasoft.net on November 21, 2000 2:34:11 PM
Nick - Head Designer, Llamasoft.net--Visit our website...Llamasoft.netGames, goodies and ingenuity
Sorry, but this is completely unrelated to your question. Have you ever heard of a guy called Jeff Minter? He was a game programming "legend" back in the days of VIC-20s and C64s. His games frequently involved sheep, camels and llamas. Guess what company name the games were published under? Llamasoft!
Search the net for "Jeff Minter" for more info.
Search the net for "Jeff Minter" for more info.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement