Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by doctorsixstring

  1. How can I determine if my app's form is currently active/in the foreground/has focus?
  2. doctorsixstring

    Color Interpolation

    This image is of three separate, overlapping triangles where each triangle has a single vertex with alpha 1.0 (the other two verts are alpha 0.0). When rendered together, the accumulated alpha at the center of the final triangle is less than 1.0 (it seems to be closer to 0.7). I expected the triangle to be 100% white (i.e. the sum of the alpha for each pixel from the three triangles is 1.0). What can I do to achieve this effect? Is it possible to adjust the color interpolation equation? FYI, I'm trying to develop an alternative solution to the "dark center of triangles" problem described in this height map rendering article.
  3. doctorsixstring

    Color Interpolation

    The article looks to be about three years old, based on the first comment in the associated thread. I just did some research on rendering heightmaps with multitexturing and shaders, and it seems promising. However, wouldn't multitexturing limit me to a small (4-8) number of terrain types? I suppose that many terrain types would be pushing it for a heightmap, anyways. For curiosity's sake, is there any solution to the original question?
  4. doctorsixstring

    relative path for image.load()

    Wow, you learn something every day. Hollower's comments make more sense now. I'll keep that in mind, since I want to support Mac with my Python game development, which has so far been limited to Windows and Linux.
  5. doctorsixstring

    relative path for image.load()

    The simplest solution is to just store your art in the same directory as your py script, and use a relative path to load it.
  6. doctorsixstring

    Gravity and Solid?

    OpenGL is only a graphics library. It won't help you with physics (gravity) or collision detection with walls and other entities in your game world. Look for some decent articles or libraries under those topics.
  7. doctorsixstring

    GLSL tc_offset variable

    Quote:Original post by Yann L Keep in mind that uniforms declared without being actively used by the shader will be optimized away by the GLSL compiler. That makes perfect sense, and I immediately noticed the problem after reading this. If you look closely at the code in my original post, you'll notice that I was simply setting gl_FragColor = sample[1]. A multi-line comment was started (but not ended) after that, so the tc_offset usage was optimized away. I just changed it to the following code, and glGetUniformLocation returns 1 for the variable, and glGetProgramiv with GL_ACTIVE_UNIFORMS returns 2. gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; Thanks!
  8. I'm trying to implement the blur fragment shader from the OpenGL Superbible, but I'm confused as to where the tc_offset variable is being set. Here's the code: uniform sampler2D sampler0; uniform vec2 tc_offset[9]; void main(void) { vec4 sample[9]; for( int i = 0; i < 9; i++ ) { sample = texture2D( sampler0, gl_TexCoord[0].st + tc_offset ); } // 1 2 1 // 2 1 2 / 13 // 1 2 1 gl_FragColor = sample[1];/*(sample[0] + (2.0*sample[1]) + sample[2] + (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; } Is tc_offset automatically set to the texture coordinates of the neighboring texels, like sampler0 is automatically set to the first texture unit?
  9. doctorsixstring

    GLSL tc_offset variable

    That makes sense. I did some reading on glGetUniform, and it looks like I first need to query the location of a uniform variable with glGetUniformLocation() before setting it with glUniform(). If that's the case, then I'm not sure what I'm doing wrong. Calling glGetUniformLocation for the tc_offset variable returns -1. Calling it for sampler0 returns 0, so that seems to indicate a problem with tc_offset. I also tried creating other variables (e.g. "uniform int a;"), but -1 was returned for those, too. I also noticed that calling glGetProgramiv with GL_ACTIVE_UNIFORMS returned 1, regardless of how many uniform variables I declared. Here's a code snippet. I'm using Python, but the GL calls should be clear regardless: self.program = glCreateProgram() glAttachShader(self.program, fragmentShader) glLinkProgram(self.program) glValidateProgram(self.program) print glGetUniformLocation( self.program, "sampler0" ) # returns 0 print glGetUniformLocation( self.program, "tc_offset" ) # returns -1 That code is executed after creating and compiling the shader (stored in the fragmentShader variable).
  10. doctorsixstring

    What is best language for 2D game ?

    Python does have type safety. It does type-checking at runtime, rather than compile time. In other words, its type-checking is dynamic, rather than static. Also, Python is not a new language by any stretch. The version appeared in '91. It is very robust and has a huge community behind it. As for the OP, I agree with the earlier recommendations for C# w/ XNA or Python w/ Pygame (or Pyglet). I use Python for my gamedev, and C# at work.
  11. doctorsixstring

    Hitpoints Outdated ?

    An Alternative View of "Hit Points"
  12. doctorsixstring

    Hitpoints Outdated ?

    Quote:Original post by lostzac ...I just think no matter what level you are you get whacked on a few times with a sword you should feel it or be going lacks a certain realism. I remember hearing somewhere about hit points representing both physical health and a character's ability to avoid being hit. You could say that a player with 100 hit points could still be killed by a single sword strike, but he is five times better at dodging than a character with 20 hit points. You could probably come up with other reasons to suit your game.
  13. doctorsixstring

    Saving files in Python

    Check out the pickle module for serializing objects into strings that can be read from and written to files. There is even an example showing how to write a serialized object to a file.
  14. doctorsixstring

    Motion equation with gravity

    Thanks for the replies, guys. I'll go ahead and start working on using fixed-length time steps, and running one or more updates per frame, depending on frame length. I'll apply gravity, ship thrust, and other external forces as a summed acceleration vector at the start of each frame. Since we've established that it would be extremely difficult to create a single formula, I won't be able to use it to solve for vehicle thrust with a desired final position. So in order to calculate power and angle of launched missiles, it sounds like I'll need to use brute force to calculate a solution. I will calculate each frame's update logic ahead of time and see where the missile will end up. If it misses, I'll keep re-running the trajectory calculation for a slightly changed power/angle until the missile hits. This seems pretty computationally expensive, but I don't see any other way.
  15. doctorsixstring

    Motion equation with gravity

    Given the motion equation (d = v*t + 0.5*a*t2), I can find a vehicle's position after a given passage of time with a given starting velocity and constant acceleration. Solving this equation for two dimension allows me to calculate spaceship movement in a Gravity Wars-style game. That same formula can also be used by missiles that the ships will shoot at each other. Now I want to throw in some gravity wells (planets, black holes, etc.). How can I calculate the final position of a missile or ship at a given time, with an initial velocity, acceleration, and one or more sources of gravity? Is there a formula for calculating the trajectory of a vehicle with those parameters? I know I could simply apply gravity to the ship's position each game tick, but that would yield different results depending on the length of each tick. I would really like a solution that yields identical results regardless of the change in time. Any thoughts? - Mike
  16. doctorsixstring

    Newbie lost in space game

    Quote:Original post by Lezbein Can anyone elaborate on this idea any more? Explaining a direct example,like how would the program calculate a mountain from a far then near? Or how would a seem less entry from space into the planet's atmosphere -through the clouds then to the the ground- all work? Check out fractals and Perlin noise. Fractal Fractal Landscape Perlin Noise
  17. doctorsixstring

    problem downloading a module in python

    You need to install the setuptools module. Install that first, then follow Hollower's directions to install gasp.
  18. doctorsixstring


    Your code worked fine for me in IDLE. However, closing the window crashed IDLE. This is a known "issue" with IDLE and Pygame: The pygame screen does not exit correctly in IDLE. Is that the crash you're referring to? I'd recommend saving your code to a text file with a .py extension and running it with the python interpreter. If you're using Windows, simply double-click on your .py file to run it. For your second question, Python file operations are relative to the current directory, which is usually the directory where your script is located.
  19. doctorsixstring


    Are you running Python from the command line? Or are you using IDLE or some other IDE?
  20. doctorsixstring

    importing part of a module automatically

    You can also import individual objects from a module, like this: "from globals import foo". You could then call the foo() method as if you declared it in the local module. That method has the benefit of not "polluting" your local namespace with unnecessary objects. Further Reading
  21. doctorsixstring

    python debugger

    Quote:Original post by pinacolada In my code I have a version of assert that I sprinkle everywhere, and it just calls "pdb.set_trace()" if the condition is false. It saves a ton of time because I don't need to go play detective, I can immediately find out why something went wrong. That is a fantastic idea. Are you doing something like this? def _assert(exp, msg=""): if __debug__ and not exp: import pdb print "_assert failed:", msg pdb.set_trace()
  22. I have successfully made a call to the Win32 API ShellExecuteEx function from my C# app (a game resource manager). I did this so that I can open resources from my app via a "Open With..." dialog (after extraction of the file to the TEMP folder). This also allows users to specify what application they want to use to open a file with an unknown extension (you know, the "Windows cannot open this file:" dialog). When a resouce file is opened, the resource editor creates a thread that monitors the file for changes. When changes are detected, the app asks the user if they want to update the archive with the changes (like WinZip). My next problem is getting a handle to the application process generated after the "Windows cannot open this file:" dialog. I want to be able to grab the process handle of Photoshop, Notepad, or whatever, so I know when the application closes and I can close the thread that monitors the file. The API documentation says to set the SHELLEXECUTEINFO structure's 'mask' property to SEE_MASK_NOCLOSEPROCESS. As you can see in the code below, I am doing this, but the hProcess property always returns a 0. I also overrode the form's WndProc() method so I can see if any related messages are received from the API (none are). A possible problem could be that ShellExecuteEx() returns immediately, and does not wait for the application-selection dialogs to be completed by the user. Obviously, it wouldn't know about any process if the property is getting set before the user picks an application. So, how can I get ShellExecuteEx() to return the process of the executed application? Also, if anyone knows of a better/easier way to accomplish all this (especially w/o calling the API directly), feel free to let me know! Here is the code I used to call ShellExecute: class FileForm { /* tons of other stuff */ [DllImport("Shell32.dll")] public static extern int ShellExecuteEx(SHELLEXECUTEINFO lpExecInfo); protected override void WndProc(ref Message m) { base.WndProc(ref m); } private void OpenFile(string filepath) { if(File.Exists(filepath)) { try { System.Diagnostics.Process.Start(filepath); } catch(System.ComponentModel.Win32Exception ex) { if( ex.NativeErrorCode == 1155 ) // 1155 = ERROR_NO_ASSOCIATION { const int SEE_MASK_NOCLOSEPROCESS = 64, // 0x00000040 SW_SHOWNORMAL = 1; SHELLEXECUTEINFO ei = new SHELLEXECUTEINFO(); ei.cbSize = 60; // sizeof(SHELLEXECUTEINFO); ei.fMask = SEE_MASK_NOCLOSEPROCESS; ei.lpVerb = "openas"; ei.lpFile = filepath; ei.nShow = SW_SHOWNORMAL; // 1 = SW_SHOWNORMAL int result = ShellExecuteEx(ei); if(result == 1) success = true; } } } else MessageBox.Show("File \"" + filepath + "\" not found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } [StructLayout(LayoutKind.Sequential)] public class SHELLEXECUTEINFO { public int cbSize = 60; public int fMask = 0; public int hwnd = 0; public string lpVerb = null; public string lpFile = null; public string lpParameters = null; public string lpDirectory = null; public int nShow = 0; public int hInstApp = 0; public int lpIDList = 0; public string lpClass = null; public int hkeyClass = 0; public int dwHotKey = 0; public int hIcon = 0; public int hProcess = 0; }
  23. doctorsixstring

    Applying Good-Evil feature onto RTSes dilemma

    After thinking about it more, I'm basically suggesting that it would simply be more costly to use units that don't align with the player's morality. The cost for an evil player to use good knights would be high, therefore the effort to use them would be higher. The cost could be pretty much anything: money, technology, spells of charisma, less effectiveness in combat, etc. The cost would increase as the player's morality changes, and not paying that cost would result in the effects we've talked about (desertion, going berserk, betraying you to the enemy, etc.) Really, it would be a pretty minor feature, and it doesn't sound like it fits with how you want your game to work.
  24. doctorsixstring

    Applying Good-Evil feature onto RTSes dilemma

    You shouldn't assume that the units would be fully aware of their leader's morality. Part of the game could be the player's attempt at placating units across the morality scale. This would involve fooling good units into thinking your orders are just, or giving evil units enough money/power/fame that they don't care who you are. So you just ordered your good-hearted knights to slaughter innocent civilians in a strategically-important town, and some of them are balking? Tell them the civilians are evil heretics/communists/terrorists, and that God wants them to be killed. Problem solved! The player's evil rating increases, but the knights don't care! The knights either became a little more evil, or a little more blind. Or, it's the end-game and you've built up an army of angelic peasants. Your good rating is practically off the scale. Unfortunately, the enemy has a giant basilisk that will easily devour your hapless peasants. You recruit an evil black dragon by convincing him that the basilisk will be denying him a healthy supply of peasant meals. You always knew he had a heart of gold! Your charisma just changed the black dragon's morality enough for it to join your army. Either that, or you'll soon have a black dragon to kill. Tracking another stat ("blindness to the truth") might be excessive, so simply making units adjust to the player's morality might be easier. This should require significant effort on the player's part, or it would lose the effect and end up like Black & White. Quote:Original post by Karnot ...clicking every unit of his, wanting to check their "morality" parameter, is quite a task, especially if it must be done regularly. That is more of a user interface problem. You could display "morality alignment" as a filled bar right next to health/morale/mana/whatever. Units with a very low value could have a dark cloud over their heads, or you could play some unhappy/grumbling sound effects when the player is nearby.
  25. doctorsixstring

    Perlin Noise Corona

    I've been playing with Perlin noise for the last few weeks, and my latest experiment is the corona effect described in Perlin's "Making Noise" presentation. Generating the static image was pretty easy. Unfortunately, converting this static image to a looping animation seems a bit more difficult. There are two things I need to do: 1) Use seamless looping 3D noise for an infinite random fluctuation. 2) Scale x and y away from center of image as z increases. Seamless looping shouldn't be hard, once I figure out the basics. However, how will seamless looping work when scaling x and y? Do I somehow need to have the values "wrap" back to the center after they "exit" the circle? - Mike
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!