[QUOTE=rute;35050895]How I deal with variables now?
[cpp]
class Test
{
public:
int num;
static DWORD WINAPI ThreadFn(LPVOID param)
{
Test *instance = (Test *)param;
while(true)
{
Test.num++;
}
return 1;
}
};
[/cpp]
Says: "a nonstatic member reference must be relative to a specific object" at num.[/QUOTE]
You'll have to access the member variable using the instance pointer:
[cpp]
class Test
{
public:
int num;
static DWORD WINAPI ThreadFn(LPVOID param)
{
Test *instance = (Test *)param;
while(true)
{
instance->num++;
}
return 1;
}
};
[/cpp]
Wondering if you guys can help me with an AC3 game.
I have 6 classes: [i]units A, B, C[/i] and [i]enemy A, B[/i] and [i]C[/i] respectively. each extends a superclass : [i]Unit[/i] (movieclip).
Presently, when a child of the units is created it is pushed into arrays unit and enemy. Looping through these arrays each child is hittested against every item in the other array. If collision is detected the child is removed and spliced.
The array system seems rather inneficient and I was wondering if there is a more efficient way to do mass collision detection.
example [url]http://www.flashkit.com/tutorials/Math-Physics/Mass_Col-Dennis_S-623/more5.php[/url] (but in AS3)
[QUOTE=Lemmingz95;35055016]Wondering if you guys can help me with an AC3 game.
I have 6 classes: [i]units A, B, C[/i] and [i]enemy A, B[/i] and [i]C[/i] respectively. each extends a superclass : [i]Unit[/i] (movieclip).
Presently, when a child of the units is created it is pushed into arrays unit and enemy. Looping through these arrays each child is hittested against every item in the other array. If collision is detected the child is removed and spliced.
The array system seems rather inneficient and I was wondering if there is a more efficient way to do mass collision detection.
example [url]http://www.flashkit.com/tutorials/Math-Physics/Mass_Col-Dennis_S-623/more5.php[/url] (but in AS3)[/QUOTE]
Thats the tough thing about collisions, is the amount of things you need to do a collision test with.
What seems to be common is to use a quadtree or octtree to subdivide entities depending on regions, then perform the logic on entities that are near each other.
[URL="http://stackoverflow.com/questions/4981866/quadtree-for-2d-collision-detection"]Here's a stack overflow entry about it.[/URL]
[QUOTE=dajoh;35053941]You'll have to access the member variable using the instance pointer:
[cpp]
class Test
{
public:
int num;
static DWORD WINAPI ThreadFn(LPVOID param)
{
Test *instance = (Test *)param;
while(true)
{
instance->num++;
}
return 1;
}
};
[/cpp][/QUOTE]
I didn't know about that. I stand corrected, thanks.
Thanks, that seems a pretty neat method..got to see how to implement it now
[QUOTE=Ehmmett;35056796][img]http://i.imgur.com/8zfrw.png[/img]
What in this is wrong? It will only collide with the first brush.
[editline]8th March 2012[/editline]
It's been a thorn in my side for the longest time too[/QUOTE]
Return false makes it only iterate through the first map.brushes, and then exit the function.
Do a return true if (...) is true,
and then after the iteration, do return false. (Remove the else)
Does anyone know of any good free C# guides/tutorials/whatever? I am using Visual C# 2010 Express and i have no idea whats going or what im doing
Trying to use SOIL but when I am compiling I get these linker errors:
[CODE]1>libSOIL.lib(stb_image_aug.o) : error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer
1>libSOIL.lib(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2[/CODE]
Yes I have linked the library in the Additional Dependencies tab, and I have included the header in my project.
Dear mystical user who replies to me,
I am constantly in a dilemma, wondering if is better to have pictures sized to all possible resolutions, or just programmaticly re size the largest picture for smaller screens. Also I'm talking about the screen differences of iPad retina -> iPad -> iPhone retina -> iPhone
[QUOTE=SwoonPoon;35058086]Does anyone know of any good free C# guides/tutorials/whatever? I am using Visual C# 2010 Express and i have no idea whats going or what im doing[/QUOTE]
Didn't read it, but seem interesting.
[URL="http://csharp.net-tutorials.com/basics/hello-world/"]http://csharp.net-tutorials.com/basics/hello-world/
[/URL]
and msdn overview:
[URL="http://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx"]http://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx[/URL]
[QUOTE=evil-tedoz;35060486]Didn't read it, but seem interesting.
[URL="http://csharp.net-tutorials.com/basics/hello-world/"]http://csharp.net-tutorials.com/basics/hello-world/
[/URL]
and msdn overview:
[URL="http://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx"]http://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx[/URL][/QUOTE]
youre the best!
If anyone has any experience with SFGUI could you check out this porblem im having?
[url]http://sfgui.sfml-dev.de/forum/topic73-sfgui-and-rendertexture.html[/url]
I hate asking Facepunch for help, but anyways: I've been going through the [URL=http://code.google.com/p/femtolisp/]femtolisp[/URL] sources, trying to understand why it's so fast as fuck, but I'm stumped at the beginning
[CODE]
...
typedef u_int32_t value_t;
typedef int32_t number_t;
typedef struct {
value_t car;
value_t cdr;
} cons_t;
typedef struct _symbol_t {
value_t binding; // global value binding
value_t constant; // constant binding (used only for builtins)
struct _symbol_t *left;
struct _symbol_t *right;
char name[1];
} symbol_t;
#define TAG_NUM 0x0
#define TAG_BUILTIN 0x1
#define TAG_SYM 0x2
#define TAG_CONS 0x3
#define UNBOUND ((value_t)TAG_SYM) // an invalid symbol pointer
#define tag(x) ((x)&0x3)
#define ptr(x) ((void*)((x)&(~(value_t)0x3)))
#define tagptr(p,t) (((value_t)(p)) | (t))
#define number(x) ((value_t)((x)<<2))
#define numval(x) (((number_t)(x))>>2)
#define intval(x) (((int)(x))>>2)
#define builtin(n) tagptr((((int)n)<<2), TAG_BUILTIN)
#define iscons(x) (tag(x) == TAG_CONS)
#define issymbol(x) (tag(x) == TAG_SYM)
#define isnumber(x) (tag(x) == TAG_NUM)
#define isbuiltin(x) (tag(x) == TAG_BUILTIN)
...
[/CODE]
Specifically those #define's. What the Christ is going on.
In C# XNA, can there be any other causes than running threads that a program doesn't terminate when the window is closed? I'm absolutely positive that I abort all the threads I start..
In XNA, what is the best way to generate asteroids at one of the 4 sides? I want the asteroids to come and go like they're random, but I have a hard time generating their starting position.
[QUOTE=Blueridge;35069499]In XNA, what is the best way to generate asteroids at one of the 4 sides? I want the asteroids to come and go like they're random, but I have a hard time generating their starting position.[/QUOTE]
Pseudocode:
get viewport width and height
random number -100 to 0 for X pos OR width + 100
random number -100 to 0 for Y pos OR height + 100
Edit: It's OK if it's not elegant. You could do a random number 1-4 and use a switch statement to determine which side to put it on and generate a random position.
[QUOTE=no-named;35068529]In C# XNA, can there be any other causes than running threads that a program doesn't terminate when the window is closed? I'm absolutely positive that I abort all the threads I start..[/QUOTE]
Well you can do it the lazy way and just set your threads to be background ones.
Oops, I just noticed this thread. So I guess I will move my question here instead.
Hey guys, I could use some help. I think i'm dealing with some black magic shit. I have a byte array where i'm holding a program. I read some strings from a chunk into a treeview. When edited the entire chunk gets regenerated because of length/offset changes and then written back to the byte array and I reload the chunk back into the treeview so the program knows the new length's and offsets. But after the first edit no more changes can be saved to the file. But the data in the array gets updated fine and the new changes show up in the treeview.
Here's the code used.
Write:
[url]http://pastebin.com/LdZuN8zV[/url]
Read:
[url]http://pastebin.com/i9Y3g2rM[/url]
Save:
[url]http://pastebin.com/Kxf7VF0h[/url]
Also I want to note, Ignore the Read/Write Process Memory. Thats only active when I have the exe running through my program and well. (I made sure ReadProcess was null before asking this)
Also if you need more code Ill be happy to provide it.
In XNA, I have a method that's being called from within my update method. Inside it, it's detecting keystrokes. Each time a key is pressed, I want it to increase an integer ONCE. Not each time the method is called. This is my current code, but it fails to work, and increases every time the method is called. Any suggestions?
[csharp]
if (ks.IsKeyDown(Keys.Up) && previousKS.IsKeyUp(Keys.Up))
{
refTileID += 1;
}
[/csharp]
[QUOTE=Mr. Smartass;35074231]In XNA, I have a method that's being called from within my update method. Inside it, it's detecting keystrokes. Each time a key is pressed, I want it to increase an integer ONCE. Not each time the method is called. This is my current code, but it fails to work, and increases every time the method is called. Any suggestions?
[csharp]
if (ks.IsKeyDown(Keys.Up) && previousKS.IsKeyUp(Keys.Up))
{
refTileID += 1;
}
[/csharp][/QUOTE]
you need to post the code that shows you setting the values of ks and previousKS
[editline]10th March 2012[/editline]
in theory what you're doing should work, so i assume you're not properly logging the previous keystroke
[QUOTE=Kopimi;35074600]you need to post the code that shows you setting the values of ks and previousKS
[editline]10th March 2012[/editline]
in theory what you're doing should work, so i assume you're not properly logging the previous keystroke[/QUOTE]
[csharp]
protected void keyboard(GameTime gameTime)
{
KeyboardState previousKS = new KeyboardState();
KeyboardState ks = Keyboard.GetState();
if (ks.IsKeyDown(Keys.Up) && previousKS.IsKeyUp(Keys.Up))
{
refTileID += 1;
}
previousKS = ks;
[/csharp]
Make previousKS an instance variable in the class and remove the "KeyboardState previousKS = new KeyboardState();" line. Right now what you're doing is saying that the previous keyboard state is actually just a blank state, comparing the current state with a blank state, then setting the blank state to the current state. Both states are deleted at the end of the method.
[QUOTE=robmaister12;35074994]Make previousKS an instance variable in the class and remove the "KeyboardState previousKS = new KeyboardState();" line. Right now what you're doing is saying that the previous keyboard state is actually just a blank state, comparing the current state with a blank state, then setting the blank state to the current state. Both states are deleted at the end of the method.[/QUOTE]
You are god
My level editor now works
[img]http://i.imgur.com/GXnY4.png[/img]
- snip, I'm late -
(New to OpenGL, sorry if this is a stupid question)
I have two different images, one for the ball and one for the paddle. When it goes to draw them instead of drawing the ball texture it still draws the paddle texture. Why is this happening? Here are the Draw functions (I'm using SOIL to load the images):
Ball:
[CODE]glPushMatrix();
glTranslatef(x,y,0);
glEnable(GL_TEXTURE_2D);
glBindTexture(BallImg , GL_TEXTURE_2D);
glBegin(GL_QUADS);
glVertex2f(-20,-20);
glTexCoord2f(0,0);
glVertex2f(20,-20);
glTexCoord2f(0,1);
glVertex2f(20,20);
glTexCoord2f(1,1);
glVertex2f(-20,20);
glTexCoord2f(0,1);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();[/CODE]
Paddle:
[CODE]glPushMatrix();
glTranslatef(x,y,0);
glEnable(GL_TEXTURE_2D);
glBindTexture(PadImg , GL_TEXTURE_2D);
glBegin(GL_QUADS);
glVertex2f(-w,-10);
glTexCoord2f(0,0);
glVertex2f(w,-10);
glTexCoord2f(1,0);
glVertex2f(w,10);
glTexCoord2f(1,1);
glVertex2f(-w,10);
glTexCoord2f(0,1);
glEnd();
glDisable(GL_TEXTURE_2D);
glPopMatrix();[/CODE]
Don't use immediate mode, it's deprecated, slow, and you won't really learn anything from it.
[QUOTE=Eudoxia;35068491]I hate asking Facepunch for help, but anyways: I've been going through the [URL=]femtolisp[/URL] sources, trying to understand why it's so fast as fuck, but I'm stumped at the beginning
[CODE]
...
typedef u_int32_t value_t;
typedef int32_t number_t;
typedef struct {
value_t car;
value_t cdr;
} cons_t;
typedef struct _symbol_t {
value_t binding; // global value binding
value_t constant; // constant binding (used only for builtins)
struct _symbol_t *left;
struct _symbol_t *right;
char name[1];
} symbol_t;
#define TAG_NUM 0x0
#define TAG_BUILTIN 0x1
#define TAG_SYM 0x2
#define TAG_CONS 0x3
#define UNBOUND ((value_t)TAG_SYM) // an invalid symbol pointer
#define tag(x) ((x)&0x3)
#define ptr(x) ((void*)((x)&(~(value_t)0x3)))
#define tagptr(p,t) (((value_t)(p)) | (t))
#define number(x) ((value_t)((x)<<2))
#define numval(x) (((number_t)(x))>>2)
#define intval(x) (((int)(x))>>2)
#define builtin(n) tagptr((((int)n)<<2), TAG_BUILTIN)
#define iscons(x) (tag(x) == TAG_CONS)
#define issymbol(x) (tag(x) == TAG_SYM)
#define isnumber(x) (tag(x) == TAG_NUM)
#define isbuiltin(x) (tag(x) == TAG_BUILTIN)
...
[/CODE]
Specifically those #define's. What the Christ is going on.[/QUOTE]
The "TAG_" defines are basically enums. C has enums, but nobody uses them. Preprocessor definitions are pretty much idiomatic. You also see a lot of preprocessor definitions instead of constants and enums and such because preprocessor definitions can be used in some places where constants can't (array sizes are a good example).
tag() and ptr() appear to be 'bitfield'-type manipulations. Values are apparently broken up into a 'tag' part (in the lowest two bits) and a 'ptr' part (using all the rest of the bits). tag() extracts these low bits, while ptr() extracts the rest.
[code]
tag(x):
000000XX
ptr(x):
XXXXXX00
[/code]
tagptr(p, t) does the reverse process -- it combines a tag and a pointer into a single value using bitwise-OR.
number(x) converts a number to a value by shifting it two places to the left (so that the low bits can be used for a tag).
numval(x) does the reverse -- converts a value to a number by shifting it two places to the right, discarding the two low bits.
intval(x) is the same as numval, but it 'returns' an int instead of a number_t.
builtin(n) converts a value to a number and tags it as TAG_BUILTIN
iscons, issymbol, isnumber, and isbuiltin check a value for the corresponding tag.
This is all pretty standard for C.
Enums are useful for DFAs
-snip-
In XNA, i have a tilemap. Every tile in it is stored in a list. I need to store the sandpath in a separate list but still have it in the normal tile list. The path pieces have to be ordered in the list so that the first piece in the list is the one next to the green blob (start), the rest ordered on how the path goes and the last is next to the gray square (end). I have no idea how to do this. I added some numbers to the image to simply show how i want the ordered.
[t]http://i.imgur.com/xqyV1.png[/t]
Yes, this is a repost from one week ago, since no one answered it.
Sorry, you need to Log In to post a reply to this thread.