What would be a good way to make a block-based game like Collapse and figure out if the blocks meet a certain pattern?
[QUOTE=SupahVee;31552465][url]http://gamedev.stackexchange.com/questions/15621/momentum-and-order-of-update-problems-in-my-physics-engine[/url][/QUOTE]
"When a body collides with another, it transfers its velocity to the other one by simply setting the body's velocity to its own."
This is your problem. You totally disregard half the information in the system and your result doesn't really obey conservation of energy. If you have one fast-moving block and one slow moving block, you either end up with two fast-moving blocks (increasing net kinetic energy) or two slow-moving blocks (decreasing net kinetic energy).
Try setting [i]both blocks'[/i] velocities to the [i]average[/i] of the pair. This simulates a completely inelastic collision between objects of equal mass. If you find that objects have a tendency to get stuck together, you might want to add a small elastic component to the collision but I would try totally inelastic first because I think it's likely to be more well-behaved.
I have an image loaded in a byte array type thing.(RGBA)
How would I load that as a texture in OpenGL?
[QUOTE=Map in a box;31558401]I have an image loaded in a byte array type thing.(RGBA)
How would I load that as a texture in OpenGL?[/QUOTE]
Create a texture ID with glGenTextures(1, &id). Bind it with glBindTexture(GL_TEXTURE_2D, id), and load the data with glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data).
Hmm, further debugging says that the colors arent being put in the thing.. hmm.. time to figure out why. Thanks.
[editline]5th August 2011[/editline]
Ohhh yeah due to java being big-endian and the bytebuffer set to little endian stuff happened.
[editline]5th August 2011[/editline]
Who would of guessed fixing that problem wouldn't do anything.
Let's say I have a static variable, I'm using it as a singleton sort of object. This instance is declared in the same header that its class is defined in, at the bottom.
After initializing this object and setting its members, I refer to it directly in all sorts of places.
If I use it within a specific class, the members are all unset.
What could be causing this?
When I noticed it, I checked that everything was being constructed in the correct order. As a temporary solution, I added a pointer to a variable of the singleton type within the class that it didn't work in, and set it to the address of the singleton from outside the class, and it works fine.
p.s, this would be C++
First time using SFML, C# and SFML.Net 1.6
When I try to create a RenderWindow in my console app, it simply hang up, the breakpoint I set on the next line never gets hit. I literally copy and pasted the code from the docs, the console shows up but never the game window.
[csharp]
RenderWindow app = new RenderWindow(new VideoMode(800, 600), "SFML window");[/csharp]
It hangs up in this line, no error, no exception, no nothing, can somebody give me a light.
EDIT:
Moved to 2.0 and everything worked flawlessly, I'll stick with it.
Quick question... if I'm going to be using .NET in my program, should I mostly always use C# for it? And C++ for wrappers/whatever?
[QUOTE=Chrispy_645;31563269]Quick question... if I'm going to be using .NET in my program, should I mostly always use C# for it? And C++ for wrappers/whatever?[/QUOTE]
Yes you should. You can make wrappers/interfaces between C# and C++ in C# using DLLImport, but it's slower than a proper wrapper.
[QUOTE=Capsup;31553540]I'm working on my own 3d engine made with c++ and opengl, and by now I'm starting to work on things such as textures and terrain. Does anybody know of any proper books that explains the technical details of procedural generation, the math behind it etc?[/QUOTE]
This book comes recommended:
[url]http://www.amazon.com/Texturing-Modeling-Third-Procedural-Approach/dp/1558608486/ref=dp_ob_title_bk[/url]
I have a copy of it, but have not read it.
Does anyone have any reading material or tutorials for how to structure your projects or better thing like a programmer? I'm having trouble with the initial setup of programming, getting all your ideas down and how to approach certain tasks or challenges. I'm mainly working with C++ and I'm just failing at incorporating classes into my incredibly simple programs so far, and I always see people using classes in logical ways that I can never think of.
Okay, so a few days ago I just started learning Python programming on my own using [url=http://cs.simpson.edu/?q=python_pygame_examples]this[/url] as a guide.
I have the most recent version of Pygame for Python, but I don't know what I'm doing wrong. Can someone help?
[img]http://img535.imageshack.us/img535/8/screenshotsnu.png[/img]
Thanks.
It might be the name of your containing folder and/or python file.
Try renaming them to my_awesome_python_game or something.
[QUOTE=thelinx;31579817]It might be the name of your containing folder and/or python file.
Try renaming them to my_awesome_python_game or something.[/QUOTE]Still nothing.
Where exactly should Pygame be installed?
[img]http://img707.imageshack.us/img707/1551/screenshotgom.png[/img]
no dude [b]your[/b] file/containing folder shouldn't be named pygame, but you should still "import pygame"
Still nothing. Sorry, I'm completely inexperienced in programming ._.
[img]http://img24.imageshack.us/img24/3185/screenshotebj.png[/img]
This is what my C:\Python32 folder looks like.
[img]http://img842.imageshack.us/img842/2738/screenshotzq.png[/img]
I have a weird bug with my code and it must be something fairly obvious and simple but I just can't spot it. I have objects called treeControllers, which draw all the trees and things in a 800x600 area (so I can have a huge map and they only draw when you're near, quicker than having individual trees checking and whatnot).
I'm trying to let the player cut down trees for wood, so I'm first looping through all the tree controllers to see which ones are active (aka ones that are drawing trees the player can see). It then loops through all the trees in each tree controller looking for which one is at the mouse position, when it finds it it destroys it (by setting [b]treeController[i].trees[j, 3][/b] to -1) and adds the wood to the inventory.
The problem is, it adds 16 wood. And not at one go, over time as space is held. The tree disappears like it should so I know treeController[i].trees[j, 3] is set to -1 (meaning the tree is gone), yet for some reason it still increments up to 16, even if you stop holding space down then come back to where the tree once was and press space again. What have I done wrong?
[code] if (currentKeyboardState.IsKeyDown(Keys.Space))
{
loop_stop = false;
for (int i = 0; i < treeController.Count; i++) //loop through each controller
{
if (treeController[i].Active == true) //if its active
{
for (int j = 0; j < treeController[i].treeNum; j++) //loop through every tree under that controller
{
if (treeController[i].trees[j, 3] != -1){ //check the tree is active
//we check whether its the tree thats clicked on
if (Vector2.Distance(mousePos+viewPos,new Vector2(treeController[i].trees[j, 0],treeController[i].trees[j, 1])) < (treeOrigin[treeController[i].trees[j, 2]].X))
{
//remove the tree
treeController[i].trees[j, 3] = -1;
if (treeController[i].trees[j, 5] != -1){ //if it drops an item
PickupItem(treeController[i].trees[j, 5]); //take the item
}
loop_stop = true; //break out of all loops
break;
}
}
}
if (loop_stop == true)
break;
}
}
}[/code]
[QUOTE=jmanmc;31562238]Let's say I have a static variable, I'm using it as a singleton sort of object. This instance is declared in the same header that its class is defined in, at the bottom.
After initializing this object and setting its members, I refer to it directly in all sorts of places.
If I use it within a specific class, the members are all unset.
What could be causing this?
When I noticed it, I checked that everything was being constructed in the correct order. As a temporary solution, I added a pointer to a variable of the singleton type within the class that it didn't work in, and set it to the address of the singleton from outside the class, and it works fine.
p.s, this would be C++[/QUOTE]
The static type modifier specifies internal linkage, so every file including this header will have its own instance.
What you can do instead is creating a member-function like this:
[cpp]static ThisClass& GetInstance(){ static ThisClass instance; return instance; }[/cpp]
Constructions like this will also resolve any static initialization order fiasco.
What would be better to pass a reference of a camera to each baseobject in my game on creation of my object so they can use that to draw itself, or make the camera static and let the baseobjects use that to draw themselfs.
[QUOTE=ZeekyHBomb;31587461]The static type modifier specifies internal linkage, so every file including this header will have its own instance.
What you can do instead is creating a member-function like this:
[cpp]static ThisClass& GetInstance(){ static ThisClass instance; return instance; }[/cpp]
Constructions like this will also resolve any static initialization order fiasco.[/QUOTE]
Thanks, worked fantastically, and using a #define to alias the GetInstance function, I didn't even have to change the rest of my code and it looks like my old static variable.
Just do a find & replace.
How should I store each 6502 instruction set in Java? As individual functions? As a switch statement?
Each instruction or instruction set? If the former, a hashmap, if the latter, individual functions or classes.
[QUOTE=ZeekyHBomb;31599677]Each instruction or instruction set? If the former, a hashmap, if the latter, individual functions or classes.[/QUOTE]
I was thinking about making it a HashMap, but was worried about performance. I could always use the java class functions do something like:
class.getMethod("Op"+opcode) or something.
[QUOTE=Map in a box;31599523]How should I store each 6502 instruction set in Java? As individual functions? As a switch statement?[/QUOTE]
How about decoding the opcode based on its bits? You can then reduce most of the instruction set into a handful (one for each assembler keyword) of register/memory access-parametrized functions.
[url=http://www.llx.com/~nparker/a2/opcodes.html]Read this[/url].
Anyone know a good OpenGL learning resource? The man pages don't explain everything fully, and they're written in broken English.
[QUOTE=spear;31601039]Anyone know a good OpenGL learning resource? The man pages don't explain everything fully, and they're written in broken English.[/QUOTE]
[url=http://www.opengl.org/sdk/docs/man3]These[/url] are generally good enough for me to use as a quick reference; maybe not enough to actually learn OpenGL off though.
[url=http://www.swiftless.com/opengltuts/opengl4tuts.html]This[/url] looks like a pretty decent tutorial series, see what you think.
I'm having a linker problem with OpenGL 3.3.
I'm using the gl3.h prototypes (not loading the function pointers manually) and compiling with -lGL. Upon compiling, gcc spits out:
[code]
renderer-gl3.o: In function `kl_render_init':
/home/mike/src/kludge/renderer-gl3.c:105: undefined reference to `glGetUniformBlockIndex'
[/code]
The driver definitely has this function available:
[code]
% strings /usr/lib/nvidia-current/libGL.so|grep GetUniformBlockIndex
glGetUniformBlockIndex
GetUniformBlockIndex
[/code]
No other functions are giving me trouble. All of the new OpenGL 3 stuff links and seems to work properly, even other UBO-related functions (such as glBindBufferBase).
[editline]8th August 2011[/editline]
Nevermind, I'm an idiot.
/usr/lib/libGL.so was a symlink to mesa/libGL.so rather than nvidia-current/libGL.so.
Guess it was a packaging mistake by Ubuntu.
Anyone got some English modern OpenGL tutorials that go further than swiftless, I've followed them but it just doesn't really give you enough knowledge.
[QUOTE=ROBO_DONUT;31603189]Guess it was a packaging mistake by Ubuntu.[/QUOTE]
Or maybe it uses the latest installed package?
Sorry, you need to Log In to post a reply to this thread.