I am working on a game right now (if you want to learn more about it, find the thread on Coder's Shed ) and have been running into many issues. Some segmentation faults which I have fixed, and some other issues. Namely, in making a procedurally generated world. It seems that the integer values in my program are randomly changing. Does anyone have an explanation for this? They are not global variables, they are variables specific to a class. This problem keeps getting in my way and there is no explanation.
Last edited by 16Skittles (2012-07-31 17:45:44)
Offline
I think we might need to see your code before we can help fix the problem.
Offline
I don't really think that would help you very much, I am not changing it within my code. I have one thing to try (that will actually clean up the code) and I am about to leave on a small trip to Chicago. When I get there I will try to fix it.
Offline
Ecliptic wrote:
I think you might find more help on Coders' Shed or Stack Overflow.
My logic posting it here was that anyone not on CS would be here, and since CS is mostly an extension of the Scratch community, they would be here too.
Offline
16Skittles wrote:
Ecliptic wrote:
I think you might find more help on Coders' Shed or Stack Overflow.
My logic posting it here was that anyone not on CS would be here, and since CS is mostly an extension of the Scratch community, they would be here too.
Stack Overflow?
Offline
Skittles, make sure you're not using local variables instead of global.
i.e.
x = 20
{
local x = 29// or w.e it was
x;
}
Offline
bbbeb wrote:
Skittles, make sure you're not using local variables instead of global.
i.e.
x = 20
{
local x = 29// or w.e it was
x;
}
What? My variables are included in the declaration of the class. Like this: (not the full class declaration, just a part of it)
Class sector{ Public: Sector(int x, int y); Int x; Int y; Void foo(); Tile[10][10] tiles; } Void foo(){ //not going to post all of the code, basically it loops through and take For(int repeatx=0; repeatx<10; repeatx++){ For(int repeaty=0; repeaty<10; repeaty++){ //this renders each tile. The parameters are for the offset, so that the different sectors //render in different places. tiles[repeatx][repeaty].update(x*640, y*640); } } }
Offline
MathWizz wrote:
How much code do you have? Would it be possible to paste some?
You would get more help if you post this stuff in AT so we actually see it.
Advanced Topics? Isn't that specifically for advanced Scratch or Scratch Modification topics?
Offline
I don't know if it is possible, but it may be that the integer is simply getting corrupted by the number of times it is accessed.
Let's assume a frame rate of 30 Frames/second.
That is 30 updates of the level and each sector.
Each update cycles through 100 tiles and accesses the integer x each time.
1 second = 3,000 times accessing the integer.
Could an insane amount of times accessing a variable cause it to break?
Offline
16Skittles wrote:
I don't know if it is possible, but it may be that the integer is simply getting corrupted by the number of times it is accessed.
Let's assume a frame rate of 30 Frames/second.
That is 30 updates of the level and each sector.
Each update cycles through 100 tiles and accesses the integer x each time.
1 second = 3,000 times accessing the integer.
Could an insane amount of times accessing a variable cause it to break?
I really doubt it. You should make it cout the variable every loop so you can see when it's value is being changed, that always works for me.
Offline
poopo wrote:
16Skittles wrote:
I don't know if it is possible, but it may be that the integer is simply getting corrupted by the number of times it is accessed.
Let's assume a frame rate of 30 Frames/second.
That is 30 updates of the level and each sector.
Each update cycles through 100 tiles and accesses the integer x each time.
1 second = 3,000 times accessing the integer.
Could an insane amount of times accessing a variable cause it to break?I really doubt it. You should make it cout the variable every loop so you can see when it's value is being changed, that always works for me.
It's an OpenGL application, and when I try to use cout<<"Hello World"; nothing happens.
Offline
Maybe you can help me with this:
I am trying to make a constructor for my sector class. I have it set out like this:
sector::sector(int getx, int gety){ x=getx; y=gety; }
But when I compile, it shows an error:
No matching function to call for Tile::Tile()
While searching for a solution to my main problem, I found This. This seems to be the same problem I am finding, but can't be sure.
Offline