[QUOTE=Aerosol;16793838]Yeah, particles would be cool.
As a side note: Using XNA seems like it could definitely get in the way of writing reusable code.[/QUOTE]
It does, In a way. - But that's probably because I didn't really udnerstand it fully, Somne things just seemed overly complicated than they needed to be (Sound)
[QUOTE=jmanmc;16791330]You should check your spelling of console in the declaration.
I'm also going to take this post to show everyone my cool menu item in litestep. I simply push the windows key on my keyboard, and this nice menu pops up. All I have to do is click on my programming environment option, and it launches everything I need:
1. Zune software for the listening of beats.
2. Visual C++ for programming.
3. C++ Primer Plus for reading and learning.
All from the click of a button. It's useful as hell and looks awesome too. Instead of launched three seperate programs, I just have to click on one thing. Here's a picture of it.
[img]http://img269.imageshack.us/img269/9403/screen2gud.png[/img]
My wallpaper is pretty cool too, but I don't see it much anyway.[/QUOTE]
Those stormtroopers are NOT floating in milk..
[QUOTE=SolidusBlack;16794368]Those stormtroopers are NOT floating in milk..[/QUOTE]
But will they blend?
That is the question.
Empire smoke, don't breathe this.
I think my Colour pllette mathematics went awry somewhere, I wanted 25 USEFUL colours, not 20 pinks and ocean blue.
[img]http://i17.photobucket.com/albums/b93/tezzanator/190809-1917.jpg[/img]
I'm at a loss on how to generate a usefull palette, My game loads a file full of Hue Values (I'm going to change this to RGB) but I need to create a usefull palette.
(Not telling what Game I am cloning yet ;P)
[QUOTE=Tezza1234;16797075]I think my Colour pllette mathematics went awry somewhere, I wanted 25 USEFUL colours, not 20 pinks and ocean blue.
[img]http://i17.photobucket.com/albums/b93/tezzanator/190809-1917.jpg[/img]
I'm at a loss on how to generate a usefull palette, My game loads a file full of Hue Values (I'm going to change this to RGB) but I need to create a usefull palette.
(Not telling what Game I am cloning yet ;P)[/QUOTE]
Happened to me too when I tried to make a palette, but I eventually fixed it and used this code:
[cpp]Uint32 HSV_to_RGB(SDL_PixelFormat* format, float h, float s, float v)
{
float sat_r, sat_g, sat_b;
while (h < 0)
h += 360;
while (h > 360)
h -= 360;
if (h < 120) {
sat_r = (120 - h) / 60.0;
sat_g = h / 60.0;
sat_b = 0;
} else if (h < 240) {
sat_r = 0;
sat_g = (240 - h) / 60.0;
sat_b = (h - 120) / 60.0;
} else {
sat_r = (h - 240) / 60.0;
sat_g = 0;
sat_b = (360 - h) / 60.0;
}
if (sat_r > 1) sat_r = 1;
if (sat_g > 1) sat_g = 1;
if (sat_b > 1) sat_b = 1;
int r = (1 - s + s * sat_r) * v * 255.0f;
int g = (1 - s + s * sat_g) * v * 255.0f;
int b = (1 - s + s * sat_b) * v * 255.0f;
return(SDL_MapRGB(format,r,g,b));
}[/cpp]
[QUOTE=noctune9;16797570]Happened to me too when I tried to make a palette, but I eventually fixed it and used this code:
[cpp] Snippy the crab [/cpp][/QUOTE]
Brilliant!!! - I'll give the code a shot!
Currently working on a program that allows you to train on the Chemical elements.
I'm also trying to think of stuff I can add to it. I could add Lanthanides and Actinides, but not today.
[code]
/*
Author: Rasmus Pettersson Vik
email: rasmus.pettersson.vik@gmail.com
Do not claim this code as your own. This code is mine.
*/
#include <iostream>
#include <string>
using namespace std;
void firstChoice();
void csymbToEn();
void enToCsymb();
void enToAtNum();
void atNumToEn();
void csymbToAtNum();
void atNumToCsymb();
void key();
//These are the three main arrays used in the program. One for the Chemical symbols, one for the English names and one for the Atomic numbers.
string csymbols [] = {"Ac", "Ag", "Al", "Am", "Ar", "As", "At", "Au", "B", "Ba", "Be", "Bh", "Bi", "Bk", "Br", "C", "Ca", "Cd","Ce", "Cf", "Cl", "Cm", "Co", "Cr", "Cs", "Cu", "Db", "Ds", "Dy", "Er", "Es", "Eu", "F", "Fe", "Fm", "Fr", "Ga", "Gd", "Ge", "H", "He", "Hf", "Hg", "Ho", "Hs", "I", "In", "Ir", "K", "Kr", "La", "Li", "Lr", "Lu", "Md", "Mg", "Mn", "Mo", "Mt", "N", "Na", "Nb", "Nd", "Ne", "Ni", "No", "Np", "O", "Os", "P", "Pa", "Pb", "Pd", "Pm", "Po", "Pr", "Pt", "Pu", "Ra", "Rb", "Re", "Rf", "Rg", "Rh", "Rn", "Ru", "S", "Sb", "Sc", "Se", "Sg", "Si", "Sm", "Sn", "Sr", "Tb", "Tc", "Te", "Ti", "Tl", "Tm", "Uub", "Uug", "Uuh", "Uuo", "Uup", "Uut", "V", "W", "Y", "Zn", "Zr", "END"};
string enNames [] = {"Actinium", "Silver", "Aluminium", "Americium", "Argon", "Arsenic", "Astatine", "Gold", "Boron", "Barium", "Beryllium", "Bohrium", "Bismuth", "Berkelium", "Bromine", "Carbon", "Calcium", "Cadmium", "Cerium", "Californium", "Chlorine", "Curium", "Cobalt", "Chromium", "Cesium", "Copper", "Dubnium", "Darmstadtium", "Dysprosium", "Erbium", "Einsteinium", "Europium", "Fluorine", "Iron", "Fermium", "Francium", "Gallium", "Gadolinium", "Germanium", "Hydrogen", "Helium", "Hafnium", "Mercury", "Holmium", "Hassium", "Iodine", "Indium", "Iridium", "Potassium", "Krypton", "Lanthanum", "Lithium", "Lawrencium", "Lutetium", "Mendelevium", "Magnesium", "Manganese", "Molybdenum", "Meitnerium", "Nitrogen", "Sodium", "Niobium", "Neodymium", "Neon", "Nickel", "Nobelium", "Neptunium", "Oxygen", "Osmium", "Phosphorus", "Protactinium", "Lead", "Palladium", "Promethium", "Polonium", "Praseodymium", "Platinum", "Plutonium", "Radium", "Rubidium", "Rhenium", "Rutherfordium", "Roentgenium", "Rhodium", "Radon", "Ruthenium", "Sulfur", "Antimony", "Scandium", "Selenium", "Seaborgium", "Silicon", "Samarium", "Tin", "Strontium", "Tantalum", "Terbium", "Technetium", "Tellurium", "Thorium", "Titanium", "Thallium", "Thulium", "Uranium", "Ununbium", "Ununhexium", "Ununoctium", "Ununpentium", "Ununquadium", "Ununseptium", "Ununtrium", "Vanadium", "Tungsten", "Xenon", "Yttrium", "Ytterbium", "Zinc", "Zirconium", "END"};
int atNum [] = {89, 47, 13, 95, 18, 33, 85, 79, 5, 56, 4, 107, 83, 97, 35, 6, 20, 48, 58, 98, 17, 96, 27, 24, 55, 29, 105, 110, 66, 68, 99, 63, 9, 26, 100, 87, 31, 64, 32, 1, 2, 72, 80, 67, 108, 53, 49, 77, 19, 36, 57, 3, 103, 71, 101, 12, 25, 42, 109, 7, 11, 41, 60, 10, 28, 102, 93, 8, 76, 15, 91, 82, 46, 61, 84, 59, 78, 94, 88, 37, 75, 104, 111, 45, 86, 44, 16, 51, 21, 34, 106, 14, 62, 50, 38, 73, 65, 43, 52, 90, 22, 81, 69, 92, 112, 116, 118, 115, 114, 117, 113, 23, 74, 54, 39, 70, 30, 40, 1337};
int main()
{
firstChoice(); //Do this instead of needing to call main() from within the functions.
}
void firstChoice()
{
bool running = true;
while (running)
{
int choice;
system("cls");
cout << "Choose what you would like to do:\n\n"
"1 : Convert the English names to the corresponding Chemical symbols.\n"
"2 : Convert the English names to the corresponding Atomic number.\n\n"
"3 : Convert the Chemical symbols to the corresponding English names.\n"
"4 : Convert the Chemical Symbols to the corresponding Atomic numbers.\n\n"
"5 : Convert the Atomic numbers to the corresponding English names.\n"
"6 : Convert the Atomic numbers to the corresponding Chemical symbols.\n\n"
"7 : View the key.\n"
"8 : Exit.\n\n";
cin >> choice;
switch (choice)
{
case 1 : enToCsymb();
break;
case 2 : enToAtNum();
break;
case 3 : csymbToEn();
break;
case 4 : csymbToAtNum();
break;
case 5 : atNumToEn();
break;
case 6 : atNumToCsymb();
break;
case 7 : key();
break;
case 8 : running = false;
break;
default : cout <<
"Please enter a number ranging from 1-8\n"
"Press any key to continue...\n";
cin.ignore();
cin.get();
}
}
}
void enToCsymb()
{
int guessPage = -1; //This variable indexes the arrays.
string guess;
bool running = true;
while (running)
{
guessPage++; //Increment the indexing variable
if (csymbols [guessPage] == "END" | enNames [guessPage] == "END") //If the guessPage value has reached the end of the array.
{
running = false;
return firstChoice(); //Return to firstChoice
}
while( guess != csymbols [guessPage] ) //Repeat while answer is wrong.
{
system("cls");
cout << enNames [guessPage] << endl; // Display the current English name.
cin >> guess;
if (guess != csymbols [guessPage]) //If the answer is wrong.
{
cout << "Wrong, try again.\n";
}
else //If the answer is correct.
{
cout<< "Correct!\n";
}
cout << "Press any key to continue...\n";
cin.ignore();
cin.get();
}
}
}
void enToAtNum()
{
int guessPage = -1; //This variable indexes the arrays.
int guess;
bool running = true;
while (running)
{
guessPage++; //Increment the indexing variable
if (enNames [guessPage] == "END" | atNum [guessPage] == 1337) //If the guessPage value has reached the end of the array.
{
running = false;
return firstChoice(); //Return to firstChoice
}
while( guess != atNum [guessPage] ) //Repeat while answer is wrong.
{
system("cls");
cout << enNames [guessPage] << endl; // Display the current English name.
cin >> guess;
if (guess != atNum [guessPage]) //If the answer is wrong.
{
cout << "Wrong, try again.\n";
}
else //If the answer is correct.
{
cout<< "Correct!\n";
}
cout << "Press any key to continue...\n";
cin.ignore();
cin.get();
}
}
}
void csymbToEn()
{
int guessPage = -1;//This variable indexes the arrays.
string guess;
bool running = true;
while (running)
{
guessPage++; //Increment the indexing variable
if (csymbols [guessPage] == "END" | enNames [guessPage] == "END") //If the guessPage value has reached the end of the array.
{
running = false;
return; //Return to firstChoice
}
while( guess != enNames [guessPage] ) //Repeat while answer is wrong.
{
system("cls");
cout << csymbols [guessPage] << endl; // Display the current chemical symbol.
cin >> guess;
if (guess != enNames [guessPage]) //If the answer is wrong.
{
cout << "Wrong, try again.\n";
}
else //If the answer is correct.
{
cout<< "Correct!\n";
}
cout << "Press any key to continue...\n";
cin.ignore();
cin.get();
}
}
}
void csymbToAtNum()
{
int guessPage = -1;//This variable indexes the arrays.
int guess;
bool running = true;
while (running)
{
guessPage++; //Increment the indexing variable
if (csymbols [guessPage] == "END" | atNum [guessPage] == 1337) //If the guessPage value has reached the end of the array.
{
running = false;
return; //Return to firstChoice
}
while( guess != atNum [guessPage] ) //Repeat while answer is wrong.
{
system("cls");
cout << csymbols [guessPage] << endl; // Display the current chemical symbol.
cin >> guess;
if (guess != atNum [guessPage]) //If the answer is wrong.
{
cout << "Wrong, try again.\n";
}
else //If the answer is correct.
{
cout<< "Correct!\n";
}
cout << "Press any key to continue...\n";
cin.ignore();
cin.get();
}
}
}
void atNumToEn()
{
int guessPage = -1;//This variable indexes the arrays.
string guess;
bool running = true;
while (running)
{
guessPage++; //Increment the indexing variable
if (atNum [guessPage] == 1337 | enNames [guessPage] == "END") //If the guessPage value has reached the end of the array.
{
running = false;
return; //Return to firstChoice
}
while( guess != enNames [guessPage] ) //Repeat while answer is wrong.
{
system("cls");
cout << atNum [guessPage] << endl; // Display the current Atomic number.
cin >> guess;
if (guess != enNames [guessPage]) //If the answer is wrong.
{
cout << "Wrong, try again.\n";
}
else //If the answer is correct.
{
cout<< "Correct!\n";
}
cout << "Press any key to continue...\n";
cin.ignore();
cin.get();
}
}
}
void atNumToCsymb()
{
int guessPage = -1; //This variable indexes the arrays.
string guess;
bool running = true;
while (running)
{
guessPage++; //Increment the indexing variable
if (csymbols [guessPage] == "END" | atNum [guessPage] == 1337) //If the guessPage value has reached the end of the array.
{
running = false;
return firstChoice(); //Return to firstChoice
}
while( guess != csymbols [guessPage] ) //Repeat while answer is wrong.
{
system("cls");
cout << atNum [guessPage] << endl; // Display the current Atomic number.
cin >> guess;
if (guess != csymbols [guessPage]) //If the answer is wrong.
{
cout << "Wrong, try again.\n";
}
else //If the answer is correct.
{
cout<< "Correct!\n";
}
cout << "Press any key to continue...\n";
cin.ignore();
cin.get();
}
}
}
void key()
{
int index = 0;
system("cls");
while (csymbols [index] != "END")
{
cout << csymbols [index] << " " << enNames [index] << " " << atNum [index] << endl;
index++;
}
cout << "Press any key to continue...\n";
cin.ignore();
cin.get();
return;
}
[/code]
[QUOTE=Armandur;16797935]
Also is there some different bb-code for c++ other than [noparse][code]***[/code][/noparse]?[/QUOTE]
[noparse][cpp] and [/cpp][/noparse]
edit:
gives you this
[cpp]
int main()
{
char
return 0;
if()
while()
do
}
[/cpp]
you use [cpp] tags.
Damn ninja'd
Ok, thanks
[QUOTE=jmanmc;16792919]I know him well enough, but I don't expect you to agree since you do the same thing.[/QUOTE]
If helping people is "impressing other people" then this entire forum does it.
[QUOTE=jmanmc;16792919]I think a function call is a little more important than something that doesn't even effect how your program compiles.[/QUOTE]
Both are equally important, thus why bother were mentioned.
[QUOTE=jmanmc;16792919]He's not programming in python.[/QUOTE]
Missed the point completely.
[quote]Currently working on a program that allows you to train on the Chemical elements.
I'm also trying to think of stuff I can add to it. I could add Lanthanides and Actinides, but not today.[/quote]
Looks good so far, lots easier to debug.
Ahhh I didn't mean to start a flamewar
[QUOTE=lemongrapes;16798267]Ahhh I didn't mean to start a flamewar[/QUOTE]
See? This is why indentation is important. People start saying crazy things about supposedly showing off your indentation skills!
:P
[QUOTE=noctune9;16797570]Happened to me too when I tried to make a palette, but I eventually fixed it and used this code:
[cpp]d[/cpp][/QUOTE]
Code helped me understand Hue better, Thanks muchly!
I've now got something much, much, MUCH more usable
[IMG]http://i17.photobucket.com/albums/b93/tezzanator/190809-2032.png[/IMG]
[QUOTE=gparent;16798319]See? This is why indentation is important. People start saying crazy things about supposedly showing off your indentation skills!
:P[/QUOTE]
Actually, I use the TextFX "Reindent C++ code" in NP++. Or rather, I try to correctly indent and then I use TextFX to fix anything I might have missed/been to lazy to indent.
[QUOTE=Tezza1234;16798356]Code helped me understand Hue better, Thanks muchly!
I've now got something much, much, MUCH more usable[/QUOTE]
I'm glad I could help. :buddy:
[QUOTE=Tezza1234;16798356]Code helped me understand Hue better, Thanks muchly!
I've now got something much, much, MUCH more usable
[IMG]http://i17.photobucket.com/albums/b93/tezzanator/190809-2032.png[/IMG][/QUOTE]
You need all those greens lol?
[QUOTE=SolidusBlack;16801800]You need all those greens lol?[/QUOTE]
are you colour blind?
[QUOTE=SolidusBlack;16801800]You need all those greens lol?[/QUOTE]
There's one green.
All the others are slightly different hues.
Etc.
[QUOTE=SolidusBlack;16801800]You need all those greens lol?[/QUOTE]
Umm, there are 3?
[QUOTE=lemongrapes;16791912]Ya, anyone know any tutorials which actually indent properly? Or would I be better of buying C++ Primer Plus or something?[/QUOTE]
Indentation can be very helpful when debugging code, especially early on when you're still learning about program flow (branches, loops, function calls etc). Indenting function definitions is useful because there will be a clearer boundary between code in the global scope and code within a function (the two have different semantics), making you less prone to misplace something. It also marks the border between different function definitions better, so when you throw a quick look you don't make the wrong judgment.
Indenting branches and loops is useful for seeing the program flow easier. Python, as mentioned, relies entirely on indentation to denote program flow, which says a bit about how potent indentation is for doing just that.
There are more advantages, but I hope I made my point already :)
Thanks, ATM I'm reading the pdf of C++ primer plus, its great.
Im continuing my saga to rule php, ajax and jquery.
Our technology teacher gave us an assignment to over-engineer a solution to a problem, so I wrote a Space Invaders clone with as much OOP thrown into the mix as I could. Although, I'll admit, I've got reusable and mantainable code now :(
[media]http://img13.imageshack.us/img13/773/23303047.png[/media]
(praise the lord collision detection gets much more trivial when GetRect() comes with SFML 2)
How could it be any more trivial? It's just like AABB square collisions
Using a floatrect with its position + width and position+height and calling sf::Rect<T>::Intersect() with another (which is what it does anyway) is hella compact in a Model class. The only thing about them is that sf::Rects aren't currently used *anywhere* else within SFML.
(also, superuser is live!!!!one)
Oh hmm, I didn't really know about sf::Rect::Intersect() but I have some random ugly function
[cpp]bool squareinsquare(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) {
return x1+w1 >= x2 && x1 <= x2+w2 && y1+h1 >= y2 && y1 <= y2+h2;
}[/cpp]
Release Time!
I've now got raising and restrictions finished, and I want some people to give it a go and see if they can break it.
[url]http://www.mediafire.com/download.php?juzvzjyymmz[/url]
I've included the source code as well for anyone who wants to have a look. Feel free to use it in your own projects, so long as you don't try to take credit for it!
Controls:
Left Click: Raise Point ( this will try to raise a point while the left mouse button is clicked, so be careful with precision work)
Right Click : Raise Square (see above)
Arrow Keys: Scrolling round map
Bug report incoming!
[IMG]http://i26.tinypic.com/2vlwnwz.png[/IMG]
The colours don't match on that surface.
Sorry, you need to Log In to post a reply to this thread.