Nah, i don't visit waywo to see "Im having a problem with something" which is generally a misunderstanding of how a language operates
Nah, i don't visit waywo to see "Im having a problem with something" which is generally a misunderstanding of how a language operates
I don't know, I'm extremely new to c# (about... 8 hours total?); The value is pulled from a textbox, but has a default value like so:
(the forums star out the control characters in my blacklist)CharacterBlacklist = "*;*;*;";
and I use it like this
private string Filter(String filterMe, Boolean fileName) { if (!string.IsNullOrEmpty(sets.CharacterBlacklist)) { char[] delim = {';'}; string[] blacklist = sets.CharacterBlacklist.Split(delim, StringSplitOptions.RemoveEmptyEntries); foreach (string c in blacklist) { filterMe = filterMe.Replace(c, ""); //Get rid of all those nasty nasty unicode chars } if (!fileName) { filterMe = filterMe.Replace("\r", "").Replace("\n", "\r\n"); //Fix the line endings for multiline pastes when logging } } return filterMe; // HAVE AT THEE }
I don't know what a List is (yet).
Ideally I'd like to be able to auto-convert characters added to the textbox into \u format (so if you put f in the textbox and then saved, it would show as \u0066), but I'm getting confused in my head how that would work and how to read them back in
... a blacklist of unicode characters? There are hundred of thousands of unicode characters. What exactly are you trying to do?
It's user customizable (no way in hell I would maintain a generic blacklist of bad unicode chars), and it's for chat logging, so the logger just doesn't log those characters to file.
Why does the chat user want to maintain a blacklist of unicode characters for logging?
Because people like to put certain special characters in their steam names and some of them royally fuck up (the ability to read) logging as a result.
Can I actually get some help?
I visit WDYNHW regularly, and I think questions belong here, not in WAYWO.
Actually, I don't think I read WAYWO v17 at all, because the level of "traffic" in WAYWO sometimes takes more time to read and respond to than I really want to devote to it.
You should convert the input string to UTF-32 (i.e. int[]), and also store the blacklist as a list of UTF-32 characters. That way you can simply compare their numeric values, and easily generate a string of the "\uXXXX" format should you need it.
You can use the StringInfo class to convert a string to UTF-32 characters.
I wasn't insinuating that the user didn't need it, I genuinely wanted to know why.
I really broke this. First time writing such a complex script (for me). The switch and cases are all messed up. Wants case 2: to become case 3; and wants else to become else;
Its a while loop with a switch then a if then with another two ifs inside of that.
Lists 18 errors in it. PrimarilyCode:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int hhp = 5; //I'll just declare all (most) my variables here for safe keeping int mhp = 5; int mhp2; int mhp3; int hdmg; int mdmg; int nom; int fight; int name; int hacc; int def; string choice; string mname = "CRAP"; Console.WriteLine("Text Based Battle System Tech Demo"); //intro text Console.ReadLine(); Random nomr; // How many monster will you fight, 1 - 3. nomr = new Random(); nom = nomr.Next(1, 4); Random namer; //Random Name namer = new Random(); name = namer.Next(0, 4); if (nom == 1) //Random Naming { switch (name) { case 1: mname = "Hogworm"; break; case 2: mname = "Boar"; break; case 3: mname = "Death Claw"; break; } } else { switch (name) { case 1: mname = "Hogworms"; break; case 2: mname = "Boars"; break; case 3: mname = "Death Claws"; break; } } Random fightr; //If you find a fight fightr = new Random(); fight = fightr.Next(1, 10); if (fight >= 1) { Console.WriteLine("You encounter " + nom + " wild " + mname + "."); Console.ReadLine(); } else { Console.WriteLine("You dont encounter any enemies!"); Console.ReadLine(); goto A; } A:while (hhp>0 && fight>0 && hhp>0) { switch (nom) { case 1: Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); choice = Console.ReadLine(); if (choice == "attack" || choice == "Attack") { Random hdmgr; hdmgr = new Random(); hdmg = hdmgr.Next(1, 25); Random haccr; haccr = new Random(); hacc = haccr.Next(0, 101); if (hacc >= 20) //I should add the monsters damage in here too. { mhp = mhp - hdmg; Console.WriteLine(" Your attack hits the enemy. The monster has " + mhp + " health remaining"); goto A; } else { Console.WriteLine ("You miss the monster!"); goto A; } else; { Random defr; defr = new Random(); def = defr.Next(1, 101); if (def >= 35) { Console.WriteLine("You defended the enemy's attack!"); goto A; } else { mhp = mhp - hdmg; mhp = mhp + 5; Console.WriteLine ("You were unable to protect yourself from the attack!"); goto A; } } break; case 2: Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.ReadLine(); break; case 3: Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.ReadLine(); break; default; Console.WriteLine ("CRAP"); break; } } } } } } }}
; expected on else and cases
invalid expression term ':' on the cases
invalid expression term 'case'
invalid expression terme 'ese'
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Syntax error, '(' expected
Type or namespace definition, or end-of-file expected
A good idea is to start with the first error and fix that, because later errors can be caused by that one original error
It's usually the smaller problems that go here, as larger ones can often qualify as something you're working on for a longer time already.
Edited:
Did I just arrive a page late to the party?
There's a " ; " on one of your else and the case default needs a " : ", not a " ; ".
And why do you use goto ?
Not sure why I had the goto. I fixed the errors you mentioned and removed the goto. Now I am up to 22 errors just doing that.... Hmmm
Edited:
Do you mean the first error you encounter or the first in the Error List (VS2010)?
Edited:
Okay got it down to 20 Errors.
Edited:
Fuck yes. 3 errors left
Edited:
Okay, 1 error left
fix'd no errors
Edited:
Okay, still errors but at least it compiles now.
Can C# save/load a struct to file? I know it's possible in C++, I think I did fopen on the file, casted the pointer as a byte and then casted it as my struct and that filled the struct for me.
However, I don't see a simple way to do it in C# - Maybe I'm just missing the function?
Edited:
Here's how I did it in C++
Code:studiohdr_t *StudioModel::LoadModel(char *modelname) { //If they didn't specify a modelname, return 0 if (!modelname) return 0; //Load the File as a pointer FILE *pFile; long size; void *buffer; if( (pFile = fopen( modelname, "rb" )) == NULL) { //Couldn't read the file return 0; } //Find the end of the file fseek( pFile, 0, SEEK_END ); //Set the size as the end (Number of Bytes in the file) size = ftell( pFile ); //Find the start of the file again fseek( pFile, 0, SEEK_SET ); //Set the buffer to the memory allocated for the model buffer = malloc( size ); if (!buffer) { //Couldn't allocate the memory for it fclose( pFile ); //Close the file return 0; } //Read the entire file (buffer = location in memory, //size = how much memory to read, 1 = how many 'blocks' of that //much to read, and pFile = file to read fread( buffer, size, 1, pFile ); fclose( pFile ); //Close the file byte *pin; studiohdr_t *phdr; mstudiotexture_t *ptexture; char *pCdtexture2; //Version Header/ID pin = (byte *)buffer; //Cast the Version Header/ID as a studioheader struct. phdr = (studiohdr_t *)pin; //Texture ptexture = (mstudiotexture_t *) (pin + phdr->textureindex ); pCdtexture2 = phdr->pCdtexture( 0 ); if (strncmp( (const char*) buffer, "IDST", 4) && strncmp( (const char*) buffer, "IDSQ", 4)) { //ToDo: IDSQ is probably only a HL1 header. Don't need support for it. //See studio_utils.cpp line 166 from real renderer //strncmp //A value greater than zero indicates that the first character that does not //match has a greater value in str1 than in str2; And a value less than zero //indicates the opposite. //Wrong File Header! MessageBoxA( NULL, "Wrong file header!", "MDL Loader", MB_OK ); free( buffer ); return 0; } if (phdr->textureindex > 0 && phdr->numtextures <= MAXSTUDIOSKINS ) { int n = phdr->numtextures; for ( int i = 0; i < n; i++) { if (!m_ptexturecd[i]) m_ptexturecd[i] = phdr->pCdtexture( i ); } } if (!m_pstudiohdr) m_pstudiohdr = (studiohdr_t *) buffer; if (!m_ptexturehdr) m_ptexturehdr = (mstudiotexture_t *) (pin + phdr->textureindex ); return (studiohdr_t *)buffer; }
Whenever this code gets to the pixel 8, 27 I get a run time error saying "vector subscript out of range"
void WorldGen::CreateWorld() { for (int x=0; x < WorldSize.x; x++) { for (int y=0; y < WorldSize.y; y++) { sf::Color MapValue; float Rand = PerlinNoise(x,y); if (Rand > 1.f) Rand = 1.f; if (Rand < 0) Rand = 0; MapValue.r = floor(Rand * 255); MapValue.g = floor(Rand * 255); MapValue.b = floor(Rand * 255); if (x > 7 && y > 26) std::cout << "Break"; ImgTexture.SetPixel(x,y, MapValue); } } Texture.SetImage(ImgTexture); Texture.SetPosition(0,0); Texture.SetScale(2.f,2.f); }
The error is in the Image.SetPixel function itself where it tries to update the pixel (8, 27) but the image is 32 by 32. So this shouldn't be out of range. Anyone got a clue what is wrong?
God dammit. Its one if statement and it fucks me over for an hour
Same code as before, well modified a bit. One if statement is giving me some troubles.
Edited:Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int hhp = 100; //I'll just declare all (most) my variables here for safe keeping int mhp = 100; int mhp2 = 100; int mhp3 = 100; int hdmg; int mdmg; int nom; int fight; int name; int hacc; int macc; int def; string choice; string mname = "CRAP"; A:Console.WriteLine("Text Based Battle System Tech Demo"); //intro text Console.ReadLine(); Random nomr; // How many monster will you fight, 1 - 3. nomr = new Random(); nom = nomr.Next(1, 4); Random namer; //Random Name namer = new Random(); name = namer.Next(1, 4); if (nom == 1) //Random Naming { switch (name) { case 1: mname = "Hogworm"; break; case 2: mname = "Boar"; break; case 3: mname = "Death Claw"; break; } } else { switch (name) { case 1: mname = "Hogworms"; break; case 2: mname = "Boars"; break; case 3: mname = "Death Claws"; break; } } Random fightr; //If you find a fight fightr = new Random(); fight = fightr.Next(1, 10); if (fight >= 1) { Console.WriteLine("You encounter " + nom + " wild " + mname + "."); Console.ReadLine(); } else { Console.WriteLine("You dont encounter any enemies!"); Console.ReadLine(); goto A; } while (hhp>0 && fight>0 && hhp>0) { switch (nom) { case 1: B:Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.WriteLine("Monster's Health " + mhp + "."); choice = Console.ReadLine(); if (choice == "attack" || choice == "Attack") { Random hdmgr; hdmgr = new Random(); hdmg = hdmgr.Next(1, 25); Random haccr; haccr = new Random(); hacc = haccr.Next(0, 101); if (hacc >= 20) //I should add the monsters damage in here too. { mhp = mhp - hdmg; Console.WriteLine("Your attack hits the enemy. The monster has " + mhp + " health remaining"); Random mdmgr; mdmgr = new Random(); mdmg = mdmgr.Next(1, 25)- hdmg; hhp = hhp - mdmg; switch (hdmg) { case (hdmg>=1 && hdmg <=4): hhp = hhp - mdmg; hhp = hhp - 5; Console.WriteLine("Your weak attack barely hurts the monster who strikes back with ease for " +(mdmg+5)+" damage"); break; case (hdmg>=5 && hdmg <=16): Random maccr; maccr = new Random(); macc = maccr.Next (1, 100); if (macc >= 40) { hhp = hhp - mdmg; Console.WriteLine("The monster powers on attacking you for " +mdmg+ " health."); } else { Console.WriteLine("The monster misses it's attack!"); } break; case (hdmg>=17): Console.WriteLine("Your attack is so powerful the enemy is unable to counter it!"); break; } else { Console.WriteLine("You miss the monster!"); Random maccr; maccr = new Random(); macc = maccr.Next (1, 100); if (macc >= 15) { hhp = hhp - mdmg; Console.WriteLine("The monster hits you for " +mdmg+" health."); } } } } else { Random defr; defr = new Random(); def = defr.Next(1, 101); if (def >= 35 && choice == "defend" || choice == "Defend") { Console.WriteLine("You defended the enemy's attack!"); } else if (choice == "defend" || choice == "Defend") { Random hdmgr; hdmgr = new Random(); hdmg = hdmgr.Next(1, 25); Random mdmgr; mdmgr = new Random(); mdmg = mdmgr.Next(5, 11); hhp = hhp - mdmg; Console.WriteLine ("You were unable to protect yourself from the attack but took less damage!"); } else { Console.WriteLine("That is not a valid choice"); goto B; } } break; case 2: Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.ReadLine(); break; case 3: Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.ReadLine(); break; default: Console.WriteLine ("CRAP"); break; } } } } }
The else I bolded is the one giving me problems.
Edited:
Error 1 Invalid expression term 'else' 146 29 Text Based Battle System
Edited:
And also it seems to think in the switch and cases involving hdmg that they are bools?
Error 3 Cannot implicitly convert type 'bool' to 'int' 121 43 Text Based Battle System
Dude, seriously? ...
Your missing a } before the else
I'm working on an XNA game library and I have absolutely no idea how I'm going to compile content to the XNB Format.
Basically I'm making a tool to convert images & xml to xnb.
Are you sure?
Like this?
That outputs an error. I'm probly just and idiot.Code:Console.WriteLine("Your attack is so powerful the enemy is unable to counter it!"); break; } } else { Console.WriteLine("You miss the monster!"); Random maccr; maccr = new Random(); macc = maccr.Next (1, 100); if (macc >= 15) { hhp = hhp - mdmg; Console.WriteLine("The monster hits you for " +mdmg+" health."); }
Edited:
Or is that the wrong else?
Is there meant to be a question in there?
Save the struct:
Load the struct:Code:XmlSerializer writer = new XmlSerializer(mystruct.GetType()); StreamWriter file = new StreamWriter("filename.xml"); writer.Serialize(file, mystruct); file.Close();
Code:XmlSerializer reader= new XmlSerializer(mystruct.GetType()); StreamWriter file = new StreamWriter("filename.xml"); return reader.DeSerialize(file, mystruct); file.Close();
if (hacc >= 20) //I should add the monsters damage in here too. { mhp = mhp - hdmg; Console.WriteLine("Your attack hits the enemy. The monster has " + mhp + " health remaining"); Random mdmgr; mdmgr = new Random(); mdmg = mdmgr.Next(1, 25)- hdmg; hhp = hhp - mdmg; switch (hdmg) { case (hdmg>=1 && hdmg <=4): hhp = hhp - mdmg; hhp = hhp - 5; Console.WriteLine("Your weak attack barely hurts the monster who strikes back with ease for " +(mdmg+5)+" damage"); break; case (hdmg>=5 && hdmg <=16): Random maccr; maccr = new Random(); macc = maccr.Next (1, 100); if (macc >= 40) { hhp = hhp - mdmg; Console.WriteLine("The monster powers on attacking you for " +mdmg+ " health."); } else { Console.WriteLine("The monster misses it's attack!"); } break; case (hdmg>=17): Console.WriteLine("Your attack is so powerful the enemy is unable to counter it!"); break; } else {
Well there the first if never ends
Also you probably have an extra } after that else
The question is:
How do i create XNB files from images or xml files using MSBuild?
Reference the following namespaces: System.Runtime.Serialization and System.Runtime.Serialization.Formatters.Binary then do this:
First mark your struct as Serializable (Put a [Serializable] before the struct declaration), then you need
to implement the ISerializeable interface and add a new constructor:
public Something(SerializationInfo info, StreamingContext context) { Name = info.GetString("Name"); Id = info.GetInt32("Id"); } //ISerializeable member public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("Name", Name); info.AddValue("Id", Id); }
Then to serialize you can use a BinaryFormatter, here's some handy functions:
public static void Serialize(string destFilePath, ISerializable obj) { using (Stream fstream = File.Open(destFilePath, FileMode.Create)) { BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(fstream, obj); fstream.Close(); } } public static T UnSerialize<T>(string filePath) where T : ISerializable { using (Stream fstream = File.Open(filePath, FileMode.Open)) { BinaryFormatter bformat = new BinaryFormatter(); T obj = (T)bformat.Deserialize(fstream); fstream.Close(); return obj; } }
Why's that? If you import it into the Content part of your project, they'll be compiled into xnb assets on compile. That being said, there's an example on MSDN about loading content (Mostly models) in real time - It compiles it and saves it temporarily.
Fox-Face that makes no sense without any formatting.
Kukks: XML :(
I'm probably going to be storing a lot of floats, so I'd want a binary format, no? (Binary just to save time/space, not specifically cause of lots of floats)
What you said there really didnt make sense to me.
Although I replaced my code with yours and it didnt fix anything.
Yea I broke the code box by mistakeshould be good now.
So you Sereialize data, and then write the sereialized data to file, then to load you load serealized data, and unserealize it?
I'm not quite following what I have to do here. Based on "then you need to implement the ISerializeable interface and add a new constructor", I want to make a new class that extensd ISerealizeable with that constructor in it, and then make a new instance of the class to serealize my data?
I didn't understand that example all that well and basically I'm aiming for a flexible dynamic library that doesn't require you to add content beforehand..
Regarding your prob
I've never had any performance issues with XML and I have no idea how to automatically serialize to a binary format so sorry :/
Let me post a quick example, hang on
Here:
[Serializable] public struct Something : ISerializable { public string Name; public int Id; public Something(string Name, int ID) { this.Name = Name; this.Id = ID; } public Something(SerializationInfo info, StreamingContext context) { Name = info.GetString("Name"); Id = info.GetInt32("Id"); } //ISerializeable member public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("Name", Name); info.AddValue("Id", Id); } } class Program { static void Main(string[] args) { Something s = new Something("Bla", 1); Serializer.Serialize("test", s); Something s2 = Serializer.UnSerialize<Something>("test"); Console.WriteLine(s2.Name); } } public class Serializer { public static void Serialize(string destFilePath, ISerializable obj) { using (Stream fstream = File.Open(destFilePath, FileMode.Create)) { BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(fstream, obj); fstream.Close(); } } public static T UnSerialize<T>(string filePath) where T : ISerializable { using (Stream fstream = File.Open(filePath, FileMode.Open)) { BinaryFormatter bformat = new BinaryFormatter(); T obj = (T)bformat.Deserialize(fstream); fstream.Close(); return obj; } } }
You need to implement ISerializeable in your struct, which will contan only the GetObjectData method, this will be used by the BinaryFormatter to serialize your struct, and the constructor will be used by it to unserialize, then you just pass the object to it.
Let me know how this works out. You can load Texture's at run time, and it's possible to load ASCII *FBX files. However you'll have to write your own importer.
See here for an overview: http://thunderfist-podium.blogspot.c...om-loader.html
That's really the biggest flaw I see with XNA right now. Makes modding very hard.
Oh god I would have done it terribly, terribly wrong. :(
Thanks for that, I'll go implement it after I get rendering up and running again.
because i didnt change anything
try this
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int hhp = 100; //I'll just declare all (most) my variables here for safe keeping int mhp = 100; int mhp2 = 100; int mhp3 = 100; int hdmg; int mdmg; int nom; int fight; int name; int hacc; int macc; int def; string choice; string mname = "CRAP"; A:Console.WriteLine("Text Based Battle System Tech Demo"); //intro text Console.ReadLine(); Random nomr; // How many monster will you fight, 1 - 3. nomr = new Random(); nom = nomr.Next(1, 4); Random namer; //Random Name namer = new Random(); name = namer.Next(1, 4); if (nom == 1) //Random Naming { switch (name) { case 1: mname = "Hogworm"; break; case 2: mname = "Boar"; break; case 3: mname = "Death Claw"; break; } } else { switch (name) { case 1: mname = "Hogworms"; break; case 2: mname = "Boars"; break; case 3: mname = "Death Claws"; break; } } Random fightr; //If you find a fight fightr = new Random(); fight = fightr.Next(1, 10); if (fight >= 1) { Console.WriteLine("You encounter " + nom + " wild " + mname + "."); Console.ReadLine(); } else { Console.WriteLine("You dont encounter any enemies!"); Console.ReadLine(); goto A; } while (hhp>0 && fight>0 && hhp>0) { switch (nom) { case 1: B:Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.WriteLine("Monster's Health " + mhp + "."); choice = Console.ReadLine(); if (choice == "attack" || choice == "Attack") { Random hdmgr; hdmgr = new Random(); hdmg = hdmgr.Next(1, 25); Random haccr; haccr = new Random(); hacc = haccr.Next(0, 101); if (hacc >= 20) //I should add the monsters damage in here too. { mhp = mhp - hdmg; Console.WriteLine("Your attack hits the enemy. The monster has " + mhp + " health remaining"); Random mdmgr; mdmgr = new Random(); mdmg = mdmgr.Next(1, 25)- hdmg; hhp = hhp - mdmg; switch (hdmg) { case (hdmg>=1 && hdmg <=4): hhp = hhp - mdmg; hhp = hhp - 5; Console.WriteLine("Your weak attack barely hurts the monster who strikes back with ease for " +(mdmg+5)+" damage"); break; case (hdmg>=5 && hdmg <=16): Random maccr; maccr = new Random(); macc = maccr.Next (1, 100); if (macc >= 40) { hhp = hhp - mdmg; Console.WriteLine("The monster powers on attacking you for " +mdmg+ " health."); } else { Console.WriteLine("The monster misses it's attack!"); } break; case (hdmg>=17): Console.WriteLine("Your attack is so powerful the enemy is unable to counter it!"); break; } } else { Console.WriteLine("You miss the monster!"); Random maccr; maccr = new Random(); macc = maccr.Next (1, 100); if (macc >= 15) { hhp = hhp - mdmg; Console.WriteLine("The monster hits you for " +mdmg+" health."); } } } else { Random defr; defr = new Random(); def = defr.Next(1, 101); if (def >= 35 && choice == "defend" || choice == "Defend") { Console.WriteLine("You defended the enemy's attack!"); } else if (choice == "defend" || choice == "Defend") { Random hdmgr; hdmgr = new Random(); hdmg = hdmgr.Next(1, 25); Random mdmgr; mdmgr = new Random(); mdmg = mdmgr.Next(5, 11); hhp = hhp - mdmg; Console.WriteLine ("You were unable to protect yourself from the attack but took less damage!"); } else { Console.WriteLine("That is not a valid choice"); goto B; } } break; case 2: Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.ReadLine(); break; case 3: Console.WriteLine("What would you like to do?"); Console.WriteLine("attack ---- defend"); Console.WriteLine("Health " + hhp + "."); Console.ReadLine(); break; default: Console.WriteLine ("CRAP"); break; } } } } }
How would I go about limiting the number of characters in a std::string to a specific number/pixel length? (C++, Code::Blocks, SFML2)
Thank you so much! That fixed the else statement, now I just need to figure out why it thinks hdmg in the cases is a bool and not a int
(Error 1 Cannot implicitly convert type 'bool' to 'int' 121 43 Text Based Battle System)
In your switch your telling it to compare it to an int
but your case is a bool (hdmg>=1 && hdmg <=4)
Your best using an if statement there
Edited:
In your switch your telling it to compare it to an int
but your case is a bool (hdmg>=1 && hdmg <=4)
Your best using an if statement there
For monospaced fonts you can do
For variable-spaced fonts it's not so fun, since each letter can have a different length. You should probably make an educated guess on the medium size and go from there.static const float singleCharLength = sf::Text("a", font, size).GetRect().Width; const std::size_t length = static_cast<std::size_t>(desiredLength / singleCharLength); if(string.size() > length) string.resize(length);
For that to work, what do I need to change exactly?
Edit: Nevermind, I'm stupid. Thanks!
Thank you good sir! I studied the switch you made with the else than changed my whole switch to a an if like you said!
How would you Serialize a 2D array of floats, or a 2d array of a Vector3 class?
Considering this is a thread partially about Java, I thought I'd toss my problem out in the open.
Whenever I try and use the command javac, my command prompt spits back a nasty message saying "'javac' is not recognized as an internal or external command, operable program or batch file".
I checked to see if I had my eggs in the right basket with a quick java -version, and it spat back my version information correctly. Here's where I have my Java installed:
C:\Program Files\Java\jre6
C:\Program Files\Java\jdk1.6.0_25