Search found 34 matches

by Amarant
Sun Oct 10, 2010 11:00 am
Forum: Programming Discussion
Topic: how literals are stored in memory
Replies: 19
Views: 2925

Re: how literals are stored in memory

String literals are NOT on the stack, they are loaded into a read-only region of memory when you open an executable. void someFunction(char* string) { string[3] = 'u'; } int main() { someFunction("this is a string"); return 0; } When you call 'someFunction' a pointer to the string is put o...
by Amarant
Fri Jun 25, 2010 3:15 am
Forum: Programming Discussion
Topic: [RESOLVED] Endian Switching and Structs on Wii?
Replies: 7
Views: 762

Re: Endian Switching and Structs on Wii?

Instead of using typedefs (which I prefer btw) you could also use your previous struct declarations. To use those you would have to add the struct keyword every time you're referring to the structs you've declared. Example: struct MapHeader mapHeader; memset(&mapHeader, 0, sizeof(struct MapHeade...
by Amarant
Mon May 31, 2010 2:03 pm
Forum: Programming Discussion
Topic: [SOLVED] Ubuntu C++ Compiling Error
Replies: 14
Views: 1677

Re: Ubuntu C++ Compiling Error

No command 'G++' found, did you mean: Command 'c++' from package 'g++' (main) Command 'c++' from package 'pentium-builder' (universe) Command 'g++' from package 'g++' (main) Command 'g++' from package 'pentium-builder' (universe) Command 'u++' from package 'u++' (universe) G++: command not found No...
by Amarant
Fri May 28, 2010 12:28 pm
Forum: Programming Discussion
Topic: What does f mean?
Replies: 20
Views: 2544

Re: What does f mean?

32 bit floats don't hold a lot more information than 32 bit integers. They also don't hold more data than 32 bit integers. What they can do is represent much larger and much smaller values. You're still limited to the 2^32 different combinations you can make using 32 bits. The only thing that's diff...
by Amarant
Sat May 22, 2010 5:21 pm
Forum: Programming Discussion
Topic: Arrays instead of vectors
Replies: 12
Views: 1130

Re: Arrays instead of vectors

... One thing... Won't this just make it so TWO elements in the array have the same value?, I think you need to do something like: void RemoveShip(int index) { delete battleships[index]; battleship_count--; battleships[index] = battleships[battleship_count]; battleships[battleship_count = NULL; } R...
by Amarant
Sat May 22, 2010 4:58 pm
Forum: Programming Discussion
Topic: Arrays instead of vectors
Replies: 12
Views: 1130

Re: Arrays instead of vectors

I guessed correctly then ;) The example I've given will be more efficient especially for large full arrays. Since the add and remove functions don't change in performance with the size of the array. Your example will increasingly get slower if you use larger and fuller arrays. For this particular ex...
by Amarant
Sat May 22, 2010 4:44 pm
Forum: Programming Discussion
Topic: Arrays instead of vectors
Replies: 12
Views: 1130

Re: Arrays instead of vectors

There is no 'THE' way to do it. Here's something else you could do if the order of the BattleShips in the array is not important: const int MAX_AMT_OF_BATTLESHIPS = 100; Battleship *battleships[MAX_AMT_OF_BATTLESHIPS]; int battleship_count = 0; //Sample function to add a ship to the array void AddSh...
by Amarant
Thu May 20, 2010 6:59 am
Forum: Programming Discussion
Topic: how to stop from looping
Replies: 11
Views: 1160

Re: how to stop from looping

Is 'flip' supposed to be a function or a variable?

Code: Select all

flip = false; // flip is a variable ?
flip(); // or is it a function...
by Amarant
Tue Aug 04, 2009 9:26 am
Forum: Programming Discussion
Topic: File IO
Replies: 10
Views: 989

Re: File IO

I'm not sure what you mean by a GBA game multiplies the size of it by 8. When a game is put on a GBA cartridge the file size of the game is multiplied by 8, so a 1 MB game on PC would be an 8 MB game on GBA. EG: A 256 MB cartridge would only actually hold 32 MBs. You're probably confusing mega bit ...
by Amarant
Tue Jun 09, 2009 6:09 pm
Forum: Programming Discussion
Topic: Beginner's Guide to Game Programming
Replies: 32
Views: 3616

Re: Beginner's Guide to Game Programming

You don't need a copy constructor for that struct, the compiler will automatically generate code that performs a shallow copy. And since it doesn't contain any pointers that should be more than enough. One thing you should probably adjust is the drawing code you use in the allegro examples. In these...
by Amarant
Thu May 28, 2009 9:10 am
Forum: Programming Discussion
Topic: [solved]C++ Structures
Replies: 14
Views: 1533

Re: C++ Structures

Structs are only in C++ to provide backwards compatibility with C.
by Amarant
Mon May 25, 2009 7:46 am
Forum: Programming Discussion
Topic: Is it possible to load mp3 files?
Replies: 9
Views: 1098

Re: Is it possible to load mp3 files?

If MarauderIIC's suggestion doesn't fix your problem and your running the code on an operating system that has case sensitive filenames, make sure that the case of the filename is correct. Also make sure that you're using the correct mode string. As stated here ( http://www.cplusplus.com/reference/c...
by Amarant
Thu Feb 12, 2009 8:24 pm
Forum: Programming Discussion
Topic: Programming Practice
Replies: 56
Views: 6125

Re: Programming Practice

Here's my attempt at M_D_K's challenge. Since I have already seen all the other solutions I tried to solve it using a different approach. - Not using % operator. - No special code to print foobar when the number is a multiple of 3 and 5. #include <stdio.h> #include <stdlib.h> int main(int argc, char...
by Amarant
Tue Feb 03, 2009 5:24 pm
Forum: Programming Discussion
Topic: Some SDL Issues
Replies: 29
Views: 2784

Re: Some SDL Issues

AHA! Through the magic of camstudio, I caught the bugger in action! It is definitely screen-tearing, right? Also, I looked at it bit more closely, and it turns out that I was double-buffering the whole time. Would tripple-buffering help, or am I doomed to failure? That's weird, usually tearing only...
by Amarant
Tue Feb 03, 2009 5:26 am
Forum: Programming Discussion
Topic: Some SDL Issues
Replies: 29
Views: 2784

Re: Some SDL Issues

Not sure, but it seems like you're describing tearing: http://en.wikipedia.org/wiki/Screen_tearing . I read that a little while ago, I don't think that's it, since it only seems to affect moving sprites (the player and enemies). As far as I can tell the reason you say it isn't tearing is in fact th...