• What do you need help with? Version 5
    5,752 replies, posted
You're welcome. I should also add that Debian just recently introduced a new feature in the packaging system, called [url=http://wiki.debian.org/Multiarch/]multiarch[/url], which makes it possible to install libraries from multiple architectures on the same system. The main use for this is to let you easily install 32-bit library packages on a 64-bit system, without needing kluges like special packages that pretend to be 64-bit but contain 32-bit files. You just use the same packages that you would've used on a 32-bit installation of the OS. Some other distros have a more limited form of this called "biarch", which works for specific pairs of architectures, typically i386 and amd64. Debian's multiarch solution works for [i]any[/i] combination of architectures; you could, for example, install ARM libraries on your x86 PC, so that you can run ARM binaries (via [url=https://en.wikipedia.org/wiki/QEMU]qemu[/url]) without needing to set up a whole virtual machine. Multiarch is very new, though. The version of Debian that includes it was just put into pre-release freeze mode at the start of this month, and probably won't actually be released until sometime this winter. [editline]10th July 2012[/editline] [QUOTE=krazipanda;36713678]Wouldn't I have to use a float/double to make the compiler not yell at me for going over the allocated memory?[/QUOTE] Going over what allocated memory? If you declare an array of ints, the compiler allocates as much memory as is needed to hold those ints. [QUOTE=krazipanda;36713678]wait, can you have the datatype be a float for the array and then call out specific parts of it as ints? I'm not too confident on my knowledge of floats/doubles and ints.[/QUOTE] This sounds like you might actually want an array of [url=https://en.wikipedia.org/wiki/Struct_%28C_programming_language%29]structures[/url]. But you should explain more of what you're actually trying to accomplish, so we can provide better guidance.
[QUOTE=Overv;36712195]Sure. [cpp]float cell[20][20]; memset( cells, 0, sizeof( cells ) );[/cpp][/QUOTE] You could also make it a global variable so it's zero-initialized on startup ;)
[QUOTE=Wyzard;36715066]You're welcome. I should also add that Debian just recently introduced a new feature in the packaging system, called [url=http://wiki.debian.org/Multiarch/]multiarch[/url], which makes it possible to install libraries from multiple architectures on the same system. The main use for this is to let you easily install 32-bit library packages on a 64-bit system, without needing kluges like special packages that pretend to be 64-bit but contain 32-bit files. You just use the same packages that you would've used on a 32-bit installation of the OS. Some other distros have a more limited form of this called "biarch", which works for specific pairs of architectures, typically i386 and amd64. Debian's multiarch solution works for [i]any[/i] combination of architectures; you could, for example, install ARM libraries on your x86 PC, so that you can run ARM binaries (via [url=https://en.wikipedia.org/wiki/QEMU]qemu[/url]) without needing to set up a whole virtual machine. Multiarch is very new, though. The version of Debian that includes it was just put into pre-release freeze mode at the start of this month, and probably won't actually be released until sometime this winter. [editline]10th July 2012[/editline] Going over what allocated memory? If you declare an array of ints, the compiler allocates as much memory as is needed to hold those ints. This sounds like you might actually want an array of [url=https://en.wikipedia.org/wiki/Struct_%28C_programming_language%29]structures[/url]. But you should explain more of what you're actually trying to accomplish, so we can provide better guidance.[/QUOTE] yeah, sorry. I am pretty new to coding in general, so bear with me if i say some things that make no sense. I am basically trying to create a grid of 0's to start out with, and then with the mercenne twister randomly turn the 0's in to 1's. Then, have the 1's dynamically react with it's surroundings- check how many other 1's are near it, and change accordingly. The simplest form of life simulator, and I thought that it would be easiest with an array because I could say something like (pseudo code obviously) [code] (cell [3][2]) if ( cell < 1 cell[3][2] = 1){ ++counter[3]; } if (cell > 1 cell[3][2] = 1){ ++counter[3]; } if (cell > cell[][2] = 1){ ++counter[3]; } if (cell < cell[][2] = 1){ ++counter[3]; } if (counter[3]>5){ cell[3][2]=0; }else if(5>counter[3]>3){ cell[3][2]=1; } [/code] [editline]10th July 2012[/editline] I don't really know what i'm doing with this one, just gonna try taking it step by step and eventually i'll get it. Seeing as this will be my second program on my first language, some of the concepts are pretty foreign to me.
An array makes sense for that, but it sounds like you should use integers, not floats. If 0 means an empty cell, 1 means one species, 2 means another species, etc., then species values like 3.475 wouldn't make any sense. Integers are simpler to work with; generally you should use floating-point types only if you actually need to work with fractional values. (Think of [url=https://en.wikipedia.org/wiki/Scientific_notation]scientific notation[/url] that you probably learned in school — that's basically what floats are.) If you've learned about [url=https://en.wikipedia.org/wiki/Enumerated_type]enums[/url], those might be even more appropriate. An enum type works like an integer in terms of how it's stored, but you refer to the different values using custom names instead of digits. Instead of 0, 1, and 2, you could have EMPTY_CELL, ELEPHANT, and WEASEL, for example. If you want to store than a single value at each cell, that's where structures come in. For example, you might want to keep track of both the species in a cell and its current health. You'd define a structure that consists of the species number (as an integer or enum) and health value (another integer), and make an array of the structure type, and then you can refer to things like cells[3][2].species and cells[4][3].health.
[QUOTE=Wyzard;36716407]An array makes sense for that, but it sounds like you should use integers, not floats. If 0 means an empty cell, 1 means one species, 2 means another species, etc., then species values like 3.475 wouldn't make any sense. Integers are simpler to work with; generally you should use floating-point types only if you actually need to work with fractional values. (Think of [url=https://en.wikipedia.org/wiki/Scientific_notation]scientific notation[/url] that you probably learned in school — that's basically what floats are.) If you've learned about [url=https://en.wikipedia.org/wiki/Enumerated_type]enums[/url], those might be even more appropriate. An enum type works like an integer in terms of how it's stored, but you refer to the different values using custom names instead of digits. Instead of 0, 1, and 2, you could have EMPTY_CELL, ELEPHANT, and WEASEL, for example. If you want to store than a single value at each cell, that's where structures come in. For example, you might want to keep track of both the species in a cell and its current health. You'd define a structure that consists of the species number (as an integer or enum) and health value (another integer), and make an array of the structure type, and then you can refer to things like cells[3][2].species and cells[4][3].health.[/QUOTE] Won't be really dealing with anything other than random mutations (the number increasing by 1 or decreasing by 1) But just wondering, is there a way i can reference something similar to a variable from an array? Like I so i wouldn't have to make one of those things i showed above for every single point? [editline]10th July 2012[/editline] Like make it so that it starts on the first point of the array [0][0], then whenever it hits the bottom of the loop, it adds ++ to the first number, making it [1][0], and then it checks all cells around that one? So that eventually when it becomes [10][0], when it adds 1 more, it goes down a column and becomes [0][1]?
Of course. Just use variables between the brackets, e.g. cells[x][y], where x and y are int variables. You can use loops to easily traverse all the x and y values in order to "visit" each cell. If you want to refer to cells above, below, or to the side of the "current" one, you can use expressions like cells[x-1][y] or cells[x][y+1]. Just make sure that the place you're referring to actually exists within the array — if x is zero, anything involving cells[x-1] is not valid. You'll need to write code to check for that sort of thing. [editline]11th July 2012[/editline] Try this: [cpp] for (int x = 0; x < 20; x += 1) { for (int y = 0; y < 20; y += 1) { cells[x][y] = // whatever... } } [/cpp]
[QUOTE=Wyzard;36716553]Of course. Just use variables between the brackets, e.g. cells[x][y], where x and y are int variables. You can use loops to easily traverse all the x and y values in order to "visit" each cell. If you want to refer to cells above, below, or to the side of the "current" one, you can use expressions like cells[x-1][y] or cells[x][y+1]. Just make sure that the place you're referring to actually exists within the array — if x is zero, anything involving cells[x-1] is not valid. You'll need to write code to check for that sort of thing. [editline]11th July 2012[/editline] Try this: [cpp] for (int x = 0; x < 20; x += 1) { for (int y = 0; y < 20; y += 1) { cells[x][y] = // whatever... } } [/cpp][/QUOTE] But the numbers that define an array have to be constants?
You can use variables to access elements in the array.
[QUOTE=krazipanda;36717319]But the numbers that define an array have to be constants?[/QUOTE] For a multi-dimensional array, all the dimensions except the last have to be constants. But you can use a single-dimensional array, and convert the x/y pair into an array index yourself, and that way you can choose the size of the array at runtime.
So, I'm trying to use [url]http://gafferongames.com/game-physics/integration-basics/[/url] (and the famous 'fix your timestep' page after that) to get my game's physics running nicely. I'm a bit confused about the RK4 integrator, though. He has this in his evaluate function: [cpp]state.x = initial.x + d.dx*dt;[/cpp] In the integrate() function, evaluate is called four times over, then the results are used to update the position: [cpp]const float dxdt = 1.0f/6.0f * (a.dx + 2.0f*(b.dx + c.dx) + d.dx); state.x = state.x + dxdt * dt;[/cpp] This means that the position is getting updated with every call to integrate, so the object moves despite having a velocity of zero. What am I missing here?
[QUOTE=Chris220;36720833]So, I'm trying to use [url]http://gafferongames.com/game-physics/integration-basics/[/url] (and the famous 'fix your timestep' page after that) to get my game's physics running nicely. I'm a bit confused about the RK4 integrator, though. He has this in his evaluate function: [cpp]state.x = initial.x + d.dx*dt;[/cpp] In the integrate() function, evaluate is called four times over, then the results are used to update the position: [cpp]const float dxdt = 1.0f/6.0f * (a.dx + 2.0f*(b.dx + c.dx) + d.dx); state.x = state.x + dxdt * dt;[/cpp] This means that the position is getting updated with every call to integrate, so the object moves despite having a velocity of zero. What am I missing here?[/QUOTE] His evaluate() has no side effects. state is a local variable within the evaluate() function.
[QUOTE=flayne;36682464]I'm talking about the client rect rather than the window rect.[/QUOTE] [QUOTE=flayne;36671202]How do I get the proper left, top coordinates instead of 0 as the function returns. Thanks.[/QUOTE] Are you dense? Use GetWindowRect to get the x and the y position of the window and GetClientRect to get the width and the height. Alternatively use just GetWindowRect and figure out how subtraction works.
in love I have [lua] if ( love.mouse.isDown( "l" ) ) then tab[x+1][y+1] = 1 elseif ( love.mouse.isDown( "r" ) ) then tab[x+1][y+1] = 0 elseif ( love.keyboard.isDown("lctrl") and love.mouse.isDown( "l" ) ) then for i=1,HW do for j=1,HW do if(tab[i][j] == 4)then tab[i][j] = 0 end end end tab[x+1][y+1] = 4 elseif ( love.keyboard.isDown("lctrl") and love.mouse.isDown( "r" ) ) then for i=1,HW do for j=1,HW do if(tab[i][j] == 5)then tab[i][j] = 0 end end end tab[x+1][y+1] = 5 end[/lua] but im getting: [QUOTE]Error: main.lua:24: attempt to index field 'keyboard' (a nil value) stack traceback: main.lua:24: in function 'update' [string "boot.lua"]:407: in function <[string "boot.lua"]:373> [C]: in function 'xpcall' [/QUOTE]
[QUOTE=ThePuska;36721056]His evaluate() has no side effects. state is a local variable within the evaluate() function.[/QUOTE] Yeah, thanks. I just took a break and came back to have another look over my code and I had a couple fatal flaws in how I'd implemented it, including misunderstanding how the acceleration function works. It's working now, I think! Thanks for the reply! :)
I'm writing a basic physics simulation using Ogre3D and ODE, however I've ran into a bit of an issue. I have a function that simulates everything, which gets called in every frame. However, to actually be able to see what's going on I need an actual object to be rendered where ODE says it is. For this I have this line: [cpp]headNode->setPosition(dGeomGetPosition(geom));[/cpp] Which basically moves the node to where ODE says it is. However, headNode is actually declared in the go() function of my class, as where that line is called in the frameRenderingQueued() of the same class, which results in the program complaining about headNode not being declared in that scope. How would I go about fixing that? I don't want to just pass it as an argument to the frameRenderingQueued() function because I'm gonna have 20-30ish physic objects in my scene, but that's the only way I know of doing it because I'm a total beginner to game development in C++. So, what do?
Is there a generally recommended IDE for C++ that a new learning programmer wouldn't have a hard time working with?
[QUOTE=TerrorShield;36730592]Is there a generally recommended IDE for C++ that a new learning programmer wouldn't have a hard time working with?[/QUOTE] Visual C++
Code::Blocks
[QUOTE=Overv;36731173]Visual C++[/QUOTE] [QUOTE=ShaunOfTheLive;36731995]Code::Blocks[/QUOTE] Thanks for the quick replies guys, I'll look into both of them right now. Is there anything else I should know/use while I'm still in the very beginning so that I'll be better prepared for the future?
[QUOTE=TerrorShield;36732664]Thanks for the quick replies guys, I'll look into both of them right now. Is there anything else I should know/use while I'm still in the very beginning so that I'll be better prepared for the future?[/QUOTE] If you are a student, you might be able to download Visual Studio Professional from Microsoft Dreamspark, among other softwares.
[QUOTE=TerrorShield;36732664]Thanks for the quick replies guys, I'll look into both of them right now. Is there anything else I should know/use while I'm still in the very beginning so that I'll be better prepared for the future?[/QUOTE] If C++ seems to be too hard, don't give up on programming. Try some other, easier language.
I am having this problem that you guys might be able to help me with. Basically, I load data from an external Excel file, and it works fine unless I load a date. Excel displays dates as dates, but stores them as numbers. I need to parse this number into a normal date. For example, in the Excel date cell I write 12/12/2012, and it displays so. When I try to load this value with my application, it shows 41255. If I try to change the format of this cell from Date to Number, it displays 41255, but goes back to 12/12/2012 when I choose Date. I need to find an algorithm that parses numbers into dates. Please help ASAP! [editline]12th July 2012[/editline] After trying a lot of different google queries, I found what I was looking for. Here's the link: [url]http://www.codeproject.com/Articles/2750/Excel-serial-date-to-Day-Month-Year-and-vise-versa[/url]
[QUOTE=Mr Kirill;36735834]I am having this problem that you guys might be able to help me with. Basically, I load data from an external Excel file, and it works fine unless I load a date. Excel displays dates as dates, but stores them as numbers. I need to parse this number into a normal date. For example, in the Excel date cell I write 12/12/2012, and it displays so. When I try to load this value with my application, it shows 41255. If I try to change the format of this cell from Date to Number, it displays 41255, but goes back to 12/12/2012 when I choose Date. I need to find an algorithm that parses numbers into dates. Please help ASAP![/QUOTE] The 12th of December 2012 is exactly 41255 days from the 30th of December 1899. 30/12/1899 is Excel's epoch date (aka. day 0). Excel used that date instead of January 1st 1900 so that it can treat 1900 as a leap year (it's not) and simplify its internal calculations.
Ok, so I'm using the integration method described here for my game: [url]http://gafferongames.com/game-physics/integration-basics/[/url] However, I want to implement acceleration like this: [cpp]velocity.x = target_speed * alpha + current_speed * (1.0 - alpha);[/cpp] Where alpha is a number between 0 and 1 that determines how quickly the velocity reaches the target velocity. Unfortunately, I can't figure out how to fit this into the integration system I'm using, since velocity is being modified by acceleration rather than directly like I want to do... I think the solution is probably quite simple but I can't seem to figure it out. :v: [editline]12th July 2012[/editline] Hm, I think I can get it working by putting it at the top of the integrate() function, before any other processing is done... I don't know if that is the 'proper' way of doing it, though.
[QUOTE=Samuka97;36730529]I'm writing a basic physics simulation using Ogre3D and ODE, however I've ran into a bit of an issue. I have a function that simulates everything, which gets called in every frame. However, to actually be able to see what's going on I need an actual object to be rendered where ODE says it is. For this I have this line: [cpp]headNode->setPosition(dGeomGetPosition(geom));[/cpp] Which basically moves the node to where ODE says it is. However, headNode is actually declared in the go() function of my class, as where that line is called in the frameRenderingQueued() of the same class, which results in the program complaining about headNode not being declared in that scope. How would I go about fixing that? I don't want to just pass it as an argument to the frameRenderingQueued() function because I'm gonna have 20-30ish physic objects in my scene, but that's the only way I know of doing it because I'm a total beginner to game development in C++. So, what do?[/QUOTE] Anyone can help me out here? I literally have no idea what I can do.
[QUOTE=Samuka97;36738209]Anyone can help me out here? I literally have no idea what I can do.[/QUOTE] We need more code.
[QUOTE=Lord Ned;36741154]We need more code.[/QUOTE] [url=http://pastebin.com/hZapV8pP]http://pastebin.com/hZapV8pP[/url]
I only skimmed it, and I'm not experienced with ODE (but am with Bullet), and it sounds like you either need to have the entity update re-position it's position in Orge, or you need something similar to Bullet's "MotionState", which is effectively a callback function by Bullet when the physics object movies internally, allowing you to update the position that it renders in.
[QUOTE=Lord Ned;36741463]I only skimmed it, and I'm not experienced with ODE (but am with Bullet), and it sounds like you either need to have the entity update re-position it's position in Orge, or you need something similar to Bullet's "MotionState", which is effectively a callback function by Bullet when the physics object movies internally, allowing you to update the position that it renders in.[/QUOTE] Yeah, I want to re-position the sceneNode (what Ogre renders) to the position of the ODE body, but I can't do that because the sceneNode and the ODE body are not declared in the same scope, and I can't move them all to the same function. That's the problem here.
Anybody know a good resource on building makefiles under windows? Got the LUA source, been at it for about 8 hours now and made no progress. The googleing the problem seems to result in the usual *points to book about unix* answers :(.
Sorry, you need to Log In to post a reply to this thread.