Advertisement Jump to content
  • Advertisement

mwmey1

Member
  • Content Count

    25
  • Joined

  • Last visited

Community Reputation

122 Neutral

About mwmey1

  • Rank
    Member
  1. mwmey1

    2d Movement

    Hi Antonym, Instead of moving the sprite directly from the Keydown event, what I would do is to toggle a MovingUp and MovingDown value. Then in your main game loop, check these values and if they are enabled, THEN move the sprite. So if you press the Up key, MovingUp = true. If you release the Up key, MovingUp = false (using case WM_KEYUP) For example ... bool Moving[2]; // Moving[0] is up, Moving[1] is down ... case WM_KEYDOWN: { switch(wParam) { case VK_UP: { Moving[0] = true; }break; case VK_DOWN: { Moving[1] = true; }break; } }break; case WM_KEYUP: { switch(wParam) { case VK_UP: { Moving[0] = false; }break; case VK_DOWN: { Moving[1] = false; }break; } }break; And then in your main game loop ... // Check if sprite should be moving if (Moving[0]) pos.y-=3; if (Moving[1]) pos.y+=3; ... Third Question: You are doing nothing wrong, that is just how it works. The top left of your screen is where everything moves from. If you move right, that is the positive X-direction, and if you move down, that is the positive Y-direction. Hope that helps M [Edited by - mwmey1 on December 10, 2008 3:07:41 AM]
  2. mwmey1

    My first game in C++ SDL

    Nice little game mate :). Congratulations on finishing one, that happens quite rarely for me! Just out of curiosity, is it completely random, or is it biased to lose? Just an observation: I know its probably just a learning step so you didn't have 'consumer ease' in mind (which is fair enough), but using an .mp3 instead of .wav cuts the project size by about 75%. Nice work :) M
  3. Thankyou again phantom and mystb for all your help. Edit: I answered my own question, so I've removed it. [Edited by - mwmey1 on December 6, 2008 7:19:37 PM]
  4. Ah I solved it. Im sorry, I thought coroutines had to be defined in global space, but no. It was then a simple matter of rearranging my code and calling an Init Function. Thanks for the help, it was greatly appreciated. M
  5. Thanks phantom, I felt that could be the issue. To increase the complexity a bit, the script that is run depends on the NPC clicked. Am I correct that I can only have one script executing in a Lua-state at a time? How would I handle the script changes, but also avoid the re-initialisation? Perhaps I am handling the entire 'individual npc script' issue the wrong way.
  6. Thanks for the reply mystb. Everytime the mouse is clicked, the script is executed using luaL_dofile(L, scriptname); The lua-state is never closed until the program exits, so I thought the coroutine would persist through multiple executions.
  7. I'm new to coroutines and am having some issues. I have a Lua function which runs each time you click the mouse. This function resumes a coroutine, but the coroutine starts from the beginning every time instead of where it yielded. I'm not sure if I'm missing something fundamental. function onClick() coroutine.resume(co) end co = coroutine.create( function () Say( "1" ) coroutine.yield() Say( "2" ) coroutine.yield() Say( "3" ) end)Every mouse click results in an output of '1'. The happens over a number of script executions, perhaps my coroutine re-initialises each execution? Thanks M
  8. mwmey1

    Parallax techniques

    Android, It is a matter or correctly adjusting the 'Z-value' for each vertex. You don't need to adjust the X-scale as this will appear to happen automatically. If you have square tiles, the upper vertices of the bottom row must match up with the lower vertices or the second row, and so on. // this should make a single column float fStartDepth = ... // The Z value for the lowest vertices float fTileDepth = ... // The change in depth over one tile for (int y = 0; y < toprow; y++) { glVertex3f( 0.0f, 0.0f + y, fStartDepth - y * fTileDepth); glVertex3f( 1.0f, 0.0f + y, fStartDepth - y * fTileDepth); glVertex3f( 0.0f, 1.0f + y, fStartDepth - (y + 1) * fTileDepth); glVertex3f( 1.0f, 1.0f + y, fStartDepth - (y + 1) * fTileDepth); } You now just need to take into account tiling in the x direction and adjust the values to suit your application. Hope this helps, M
  9. Hey all, My aim is to have a script executing for each NPC in my game, often several at once (C++, Lua). Using one state corrupts the stack and I end up with a bunch of runtime errors because I've popped a bad value. Giving each NPC it's own lua-state seems like overkill to me. Especially since I would (correct me if I'm wrong) have to register my C++ utility functions for every state. I'm happy to do it if there's no better way. Co-routines make scripts take turns running (?), is this ideal when various scripts will be running constantly. The question really is: conceptually, how should I approach this scenario? Importance is placed on performance/reliability. Help is greatly appreciated, M [Edited by - mwmey1 on December 3, 2008 12:43:06 AM]
  10. mwmey1

    Graphics vs Gameplay

    In my opinion, graphics will become less important as the industry reaches the 'photorealistic cap'. While the graphics will still be phenomenal, anyone (basically) is capable of producing them, so they are no longer special. I know a lot of people that would agree with me when I say that awe-inspiring graphics do not ensure a good game (Assassin's Creed comes to mind), so you cant neglect the gameplay. If I wanted photo-realism in a world where nothing exciting happened, I'd peer out my window. The suspension of reality comes from great story and gameplay, and while good graphics is a fantastic bonus, I don't believe that is the 'clencher'. M
  11. mwmey1

    Extent of Lua Global Variables

    Endurion: Thankyou very much for the reply. That's good news to me :). ddn3: Thankyou also for the great amount of detail. Greatly appreciated. Quote:this method is more extreme as it doesn't allow global data to be shared between scripts So the global variables would be exposed to one script, and not the whole lua state? Just to clarify, does it allow sharing between separate executions of the SAME script? ie Is it limited to one execution or to one script? Many thanks M
  12. Hey all, Simple question: I call character-behaviour scripts each frame. Do the global variables I set in one frame retain their values when the script is executed in the next frame and so on? I would assume that they don't. If not, is there a way to implement this. I've read related questions but was unsure whether the answers referred to one script execution or many. Thanks alot, M
  13. Nicely clarified =D . Detailed and easy to follow. I've already figured this stuff out for myself, but if I had this post at the time it would have made things much easier.
  14. When I read this I instantly thought of the original 'Adventure' text game, especially that damn maze. You walk north from Room A to Room B. You then walk south from Room B ... to Room C! This was done in such a way though that it became part of the challenge, especially creating accurate maps. It was definately confusing and disorientating at times, but if the gameplay is interesting the average player should be forgiving enough, if they notice at all.
  15. mwmey1

    Scenery Depth

    Thanks for the reply Codeka. At the moment I have no algorithm at all, the scenery just has a Z position in 3D space and OpenGL's Z-sorting takes care of the rest. Your answer makes perfect sense, I'll try to write my own function to handle the sorting then.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!