Is in C# a possibility to read a (video/ audio) stream *object?
This because im reading the file out a database and not have the file (directly) on my HD or do i need to temporary create the file and delete it afterwards?
Making a hangman game in C#, I'm having trouble making it correctly print each found letter in this for loop:
[csharp]
for (int i = 0; i < word.Length; i++)
{
if (placesInWord.Contains(i)) Console.Write(word.ElementAt(i) + " ");
else Console.Write("_ ");
}
[/csharp]
It will always print the first found letter (the first time you enter a letter), after that it's somewhat random regarding what letter it prints, but not with every word somehow. I just can't figure this out on my own.
Here's the full code:
[csharp]
while (true)
{
Console.Clear();
List<int> placesInWord = new List<int>();
List<char> usedLetters = new List<char>();
int srch = 0;
Console.Write("Enter a word, lowercase: ");
string word = Console.ReadLine();
int wordSize = word.Length;
int foundLetters = 0;
char guess;
while (foundLetters < wordSize)
{
Console.Clear();
Console.Write(Environment.NewLine);
for (int i = 0; i < word.Length; i++)
{
if (placesInWord.Contains(i)) Console.Write(word.ElementAt(i) + " ");
else Console.Write("_ ");
}
Console.WriteLine(Environment.NewLine + Environment.NewLine + "Guess a letter: ");
while (true)
{
guess = Convert.ToChar(Console.ReadLine());
if (usedLetters.Contains(guess) == false)
{
while (word.IndexOf(guess, srch) != -1)
{
placesInWord.Add(word.IndexOf(guess, srch));
srch = placesInWord.Last() + 1;
}
usedLetters.Add(guess);
break;
}
else Console.WriteLine("Already used! Try again.");
}
if (word.IndexOf(guess) != -1)
{
foundLetters += word.Count(c => c == guess);
}
else
{
Console.Write("Wrong! Try again.");
Console.ReadLine();
}
}
Console.WriteLine(Environment.NewLine + "Word found." + Environment.NewLine + "It was '{0}'.", word);
Console.WriteLine("Press enter to play again.");
Console.ReadLine();
}
[/csharp]
[editline]lol[/editline]
Got it, needed to add [B][I]one[/I][/B] line:
[csharp] srch = 0;[/csharp]
[QUOTE=swift and shift;35681469]in future, compile with -Wall -Wextra -Werror -pedantic
[editline]23rd April 2012[/editline]
The -Werror forces you to fix all warnings before compiling successfully. You really should do that[/QUOTE]
Im using codeblock for writing and compiling, but what's -werror?
[QUOTE=bilbasio;35686264]Im using codeblock for writing and compiling, but what's -werror?[/QUOTE]
[QUOTE=swift and shift;35681469]in future, compile with -Wall -Wextra -Werror -pedantic
[editline]23rd April 2012[/editline]
[b]The -Werror forces you to fix all warnings before compiling successfully. You really should do that[/b][/QUOTE]
How did you even miss that??
[QUOTE=swift and shift;35681469]in future, compile with -Wall -Wextra -Werror -pedantic
[editline]23rd April 2012[/editline]
The -Werror forces you to fix all warnings before compiling successfully. You really should do that[/QUOTE]
Alternatively you could -Wall -Wextra -pedantic-errors in case you don't need to care about all them errors.
Hi, I was writing some code using Visual C++ 2010 express and I needed to create a local scope so I could use some temporary variables I was using do {/*code*/ }while(false); and it worked fine, but then I accidently backspaced the do and I noticed VC++ wasn't highlighting an error, I backspaced the while(false) (the code now looked like {/*code here*/}) as well and compiled and it succeeded, when I tried to use the variables in the brackets an error popped up. It seems like this is doing what it should do, however I have never seen this syntax before, is this correct and portable syntax?
[editline]23rd April 2012[/editline]
[QUOTE=Mr. Smartass;35681651]How can I make my project net-friendly? I don't want to add networking yet, but I want it to be possible later down the line.[/QUOTE]
You should separate client and server code. In C++ you can use #ifdef lines, find out whatever the language equivalent is if you are not using C++. Wherever you want code to only build for the server use #ifdef SERVER (or #ifdef server if you prefer) and wherever you want code to only build for the client use #ifdef CLIENT (or #ifdef client) or your language's equivalent.
[QUOTE=T3hGamerDK;35686894]How did you even miss that??[/QUOTE]
Maybe because I started programming like 1 day ago?
[QUOTE=bilbasio;35687948]Maybe because I started programming like 1 day ago?[/QUOTE]
I don't see how this inhibits your ability to read.
Anyone know what could be causing this? Everything else in the scene works perfectly apart from the objects using the instancing shader.
[IMG]http://dl.dropbox.com/u/12592785/broken.png[/IMG]
[QUOTE=robmaister12;35681112]FreeType works with Unicode (unsigned ints). For some really rare characters, you'll have trouble even with unsigned chars. Just a heads up.
If you want to load all of the glyphs in a font, you can use a combination of FT_Get_First_Char and FT_Get_Next_Char like in the example here: [url]http://freetype.sourceforge.net/freetype2/docs/reference/ft2-base_interface.html#FT_Get_First_Char[/url][/QUOTE]
Yes, that's a good tip. That's partly how I managed to track down the problem.
However, I still have a small irk. Arial tells me it has 3417 characters, but apparently it doesn't have all of the 255 ASCII-characters. These are (IIRC) character code 127 and about 33 characters on.
Here's a pic to illustrate.
[IMG]http://i.snag.gy/Ggl1l.jpg[/IMG]
Also, when I typecast my string-value to (unsigned char) it'll show the foreign characters, but if I try (unsigned int) it will give me the same result as before, where character 127 and beyond were squares. Any thought why this is the case?
first time using win32 for anything past initializing a window, having trouble accessing a process
i'm trying to find a running process and read its memory, so far i can get a HWND handle to the window and the process ID, yet when i call OpenProcess() to get a handle to the process itself, OpenProcess() fails with error code 87. error code 87 apparently means invalid parameter, yet i've verified all the parameters are valid. the HWND and the process ID are both completely valid and of the right types. here's my code
[cpp]
HWND targetHWND = FindWindow(NULL, "Untitled - Notepad");
if (targetHWND == NULL)
{
MessageBox(NULL, "Failed to find target window (ERROR 1), exiting.\n\nPlease make sure Fallout: NV is running.", "ERROR", NULL);
return 0;
}
DWORD targetPID = GetWindowThreadProcessId(targetHWND, NULL);
if (targetPID == NULL)
{
MessageBox(NULL, "Failed to find target window (ERROR 2), exiting.\n\nPlease make sure Fallout: NV is running.", "ERROR", NULL);
return 0;
}
HANDLE openHandle = OpenProcess(PROCESS_ALL_ACCESS, false, targetPID);
if (openHandle == NULL)
{
std::stringstream stream;
stream << GetLastError();
std::string string = stream.str();
OutputDebugString(string.c_str());
MessageBox(NULL, "Failed to find target window (ERROR 3), exiting.\n\nPlease make sure Fallout: NV is running.", "ERROR", NULL);
return 0;
}
[/cpp]
everything works up until you get to OpenProcess. no errors or anything, but openHandle is still NULL and so the app dies.
[B]EDIT[/B]
ok i just tested something: even though calling GetWindowThreadProcessId returns a process number, it seems like for whatever reason this process number is invalid. i used task manager and looked at the running services and there is no process with an ID (or name, i'm running notepad) that corresponds to the one that i'm getting in my application. why would that be?
In SFML, I am trying to create a hitbox for a rotated rectangle. I am getting the correct points of the rotated rectangle, however on certain angles the hitbox and rectangle don't follow the exact same path. I am getting the points and then just adding both the rect and hitbox with the same velocity each tick. The angle used for all the maths is also the same.
~I fixed it, it was an error on the way I handled conversion compensation client side~
[QUOTE=Mordi;35689625]Yes, that's a good tip. That's partly how I managed to track down the problem.
However, I still have a small irk. Arial tells me it has 3417 characters, but apparently it doesn't have all of the 255 ASCII-characters. These are (IIRC) character code 127 and about 33 characters on.
Here's a pic to illustrate.
[IMG]http://i.snag.gy/Ggl1l.jpg[/IMG]
Also, when I typecast my string-value to (unsigned char) it'll show the foreign characters, but if I try (unsigned int) it will give me the same result as before, where character 127 and beyond were squares. Any thought why this is the case?[/QUOTE]
ASCII is only defined 0-127. Everything above that is different with each encoding. With Unicode, 0x7F - 0xA0 are special characters that aren't drawn (in the same way that ASCII 0x00-0x20 are special characters that aren't drawn)
[url]http://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF[/url]
The characters you're outputting are correct under Unicode.
Any one know what happens when you draw a vbo in openGL without textures? Does it just appear invisible, or black etc ?
[QUOTE=Shrapnel :3;35697290]Any one know what happens when you draw a vbo in openGL without textures? Does it just appear invisible, or black etc ?[/QUOTE]
Depend what you have set in your frag shader
I'm not allowed to use shaders in the coursework, so it's the fixed function.
[QUOTE=Shrapnel :3;35697320]I'm not allowed to use shaders in the coursework, so it's the fixed function.[/QUOTE]
In that case its either white or black, not sure which tho.
you can set it with:
glColor3f(0.5f,0.5f,1.0f);
[QUOTE=robmaister12;35693578]ASCII is only defined 0-127. Everything above that is different with each encoding. With Unicode, 0x7F - 0xA0 are special characters that aren't drawn (in the same way that ASCII 0x00-0x20 are special characters that aren't drawn)
[url]http://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF[/url]
The characters you're outputting are correct under Unicode.[/QUOTE]
Oh! Thanks for clearing that up.
Now I'm almost completely satisfied. The only thing left for me to figure out is why casting (unsigned char) works, while casting (unsigned int) doesn't.
[QUOTE=Mordi;35697752]Oh! Thanks for clearing that up.
Now I'm almost completely satisfied. The only thing left for me to figure out is why casting (unsigned char) works, while casting (unsigned int) doesn't.[/QUOTE]
It would be really strange if casting the values weren't equal (try outputting the numbers in the console to compare them), so maybe there's an overload for unsigned chars. If so, I'll have to update my C# bindings!
Does anyone know what could be causing this?
(The sphere should be behind the cube)
[IMG]http://i.imgur.com/SvVKc.png[/IMG]
I have these enabled:
[cpp]
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
[/cpp]
Is an inherited class from an abstract base class always abstract itself? (C++)
[QUOTE=Number-41;35699274]Is an inherited class from an abstract base class always abstract itself? (C++)[/QUOTE]
Well, "abstract" in C++ just means that the class does not implement all of its declared methods. If you inherit from an abstract class and implement all the methods, then your inherited class is not abstract. Otherwise, it is.
[QUOTE=Richy19;35699081]Does anyone know what could be causing this?[/QUOTE]
This may sound like a really obvious question, but which one are you drawing first? The cube or the sphere?
[QUOTE=shill le 2nd;35699295]Well, "abstract" in C++ just means that the class does not implement all of its declared methods. If you inherit from an abstract class and implement all the methods, then your inherited class is not abstract. Otherwise, it is.[/QUOTE]
The thing is that I know have this:
[cpp]
class AbstractBase
{
public:
AbstractBase();
virtual AbstractBase operator+ (AbstractBase)=0;
}
//Headerfile for DerivedClass
#include "AbstractBase.h"
class DerivedClass: public AbstractBase
{
public:
DerivedClass(double &);
DerivedClass operator+ (DerivedClass&);
double getVar();
private:
double Var;
}
//Implementation of DerivedClass
#include "DerivedClass.h"
class DerivedClass::DerivedClass(double &Input) :Var(Input)
{}
double DerivedClass::getVar()
{
return Var;
}
DerivedClass DerivedClass::operator+ (DerivedClass object&)
{
return DerivedClass(Var+object.getVar);
}
[/cpp]
The first lines in the AbstractBase header don't work because you can't have a function that returns an abstract object. So I have to use pointers, but the implementation in the DerivedClass.cpp file doesn't work either because DerivedClass is abstract (which I don't want!)
You can return a reference or a pointer to an object of an abstract class.
[editline]24th April 2012[/editline]
Of course you can't [B]construct[/B] an object of such a class, which means it'll have to be a child class instance.
[QUOTE=Matt-;35699391]This may sound like a really obvious question, but which one are you drawing first? The cube or the sphere?[/QUOTE]
The cube
[QUOTE=esalaka;35699550]You can return a reference or a pointer to an object of an abstract class.
[editline]24th April 2012[/editline]
Of course you can't [B]construct[/B] an object of such a class, which means it'll have to be a child class instance.[/QUOTE]
How do I get my child class to be non-abstract (but still inheriting from an abstract class) then?
As said earlier, implement all nonimplemented methods.
[editline]24th April 2012[/editline]
Which means you'll have to implement exactly one: AbstractBase operator+ (AbstractBase)
[editline]24th April 2012[/editline]
(Although frankly I can't see why it isn't AbstractBase operator+ (AbstractBase&) or even AbstractBase operator+ (const AbstractBase&) const
Sorry, you need to Log In to post a reply to this thread.