trying to learn c++, at hello world stuff right now. my first time. painful.
I found out I have to use "getch" to capture keys, then VS told me "use _getch, its new and cool"
I wrote this, its under main
char ch = _getch();
if (ch == 47)
printf ("asdqwe");
What I want to do is everytime I press 47(it was / I think) I want it to print asdqwe, however it works only once.
Now I realize im dumb and this is because getch is designed to capture one char.
the problem is, how do I just capture everything everytime ?
[QUOTE=Striker26;39877755]I don't understand though, why would it resort to placing the character on the next row?[/QUOTE]
When you do Board[2] = '1', what you actually do is you set the memory address at (Board's address + 2) to '1'. You could visualize it like this in the memory:
{ ..other vars.. , Board[0] , Board[1] , Board[2] , ..other vars.. }
Now [I]I guess[/I] that if you use a 2d array, you'd get this in the memory:
{ ..other vars.. , Board[0][0] , Board[0][1] , Board[0][2] , Board[1][0] , Board[1][1] , Board[1][2] , ..etc.. }
If this is the case, Board[3] would be the same as Board[1][0].
[editline][/editline]
I've seen a question on SO once that explained that a[2] is the same as 2[a], pretty funny concept actually.
[QUOTE=Striker26;39877755]I don't understand though, why would it resort to placing the character on the next row?[/QUOTE]
In memory, multidimensional arrays are actually stored as one dimensional arrays.
So when board is 2x2,
[code]Board[0][2][/code]
really means
[code]Board[0 * 2 + 2] == Board[1 * 2 + 0] == Board[1][0] == Board[2][/code]
So it prints it out as Board[2] when you're in that row but also Board[1][0] when you start the next row.
[QUOTE=esalaka;39877261]I actually have no idea of what I was thinking because it makes no sense regardless
Was this scaling
[editline]11th March 2013[/editline]
Oh scaleM scales the [I]matrix[/I]
[editline]11th March 2013[/editline]
[B]Also not everything would be zero but by my explanation one axis would be zero and the volume would be zero, I guess.
[/B]
The area would stay the same.
I don't even know if you can do that[/QUOTE]
Yes, that's exactly what I'm trying to do. :(
[QUOTE=egomanyak;39877776]trying to learn c++, at hello world stuff right now. my first time. painful.
I found out I have to use "getch" to capture keys, then VS told me "use _getch, its new and cool"
I wrote this, its under main
char ch = _getch();
if (ch == 47)
printf ("asdqwe");
What I want to do is everytime I press 47(it was / I think) I want it to print asdqwe, however it works only once.
Now I realize im dumb and this is because getch is designed to capture one char.
the problem is, how do I just capture everything everytime ?[/QUOTE]
You need to make a loop and loop around the code that does something when a button is pressed.
[QUOTE=Shadaez;39878463]You need to make a loop and loop around the code that does something when a button is pressed.[/QUOTE]
any loop I make acts as if I always held that key surely im missing something here
[QUOTE=egomanyak;39878504]any loop I make acts as if I always held that key surely im missing something here[/QUOTE]
is your "char ch = _getch();" code in the loop too? should be something like
[code]
While True
{
char ch = _getch(); //it needs to get a new character every loop
if (ch == 47) //and then check if the character got is the one pressed
{
printf ("asdqwe"); //do something if it's pressed
}
}
[/code]
so it updates
[editline]11th March 2013[/editline]
psuedocode btw idk C++ syntax
[QUOTE=Shadaez;39878549]is your "char ch = _getch();" code in the loop too? should be something like
[code]
While True
{
char ch = _getch(); //it needs to get a new character every loop
if (ch == 47) //and then check if the character got is the one pressed
{
printf ("asdqwe"); //do something if it's pressed
}
}
[/code]
so it updates
[editline]11th March 2013[/editline]
psuedocode btw idk C++ syntax[/QUOTE]
yeah I didnt realized it should be within loop as well. thank you.
on a unrelated topic may I ask how many times per second these infinite loops run ?
[QUOTE=egomanyak;39878602]yeah I didnt realized it should be within loop as well. thank you.
on a unrelated topic may I ask how many times per second these infinite loops run ?[/QUOTE]
A second / how long as it takes to perform whatever action is inside the loop.
That depends on what hardware you're running it on, and what is running in the background. An itteration through your code is called a tick, which is similar to a frame in games. So your ticks per second depends on how quick your machine and code is. Since you have very little code, that is executed really quickly, we're talking at least a couple(hundred?) thousand times a second here.
[editline]11th March 2013[/editline]
Also, if you don't want to have to find which keycode each character has, you can put a character in single quotes, and it'll be the same.
But I/O operations are slow, so if you had a loop without any, it would run a lot faster. Of course sometimes its unavoidable but I guess it's something to keep in mind.
Visual Studio 2012 needs a key, which is free but the sign up pages requires my business information. But im not part of any business? What do I do?
[QUOTE=a-k-t-w;39885080]Visual Studio 2012 needs a key, which is free but the sign up pages requires my business information. But im not part of any business? What do I do?[/QUOTE]
Through which business do you get your free key? School?
[QUOTE=mobrockers2;39885188]Through which business do you get your free key? School?[/QUOTE]
what? after 30 days visual studio asks for a key and gives you this link [url]http://go.microsoft.com/fwlink/?linkid=244593&clcid=0x409[/url]
it never asked for business information for previous versions but now it does.
[QUOTE=a-k-t-w;39885402]what? after 30 days visual studio asks for a key and gives you this link [url]http://go.microsoft.com/fwlink/?linkid=244593&clcid=0x409[/url]
it never asked for business information for previous versions but now it does.[/QUOTE]
Well you said visual studio and not visual studio express..
whoops my bad.
I think I just filled in "Microsoft" as the name of the company :v:
Try to fill in N/A or just random values if that doesn't work. I doubt that they actually go over every express user to check if the companies are real.
Hey, so I just got Visual Studio 2012 to cooperate with their git extension. Now I tried to create a new branch, but whenever I do it displays this:
[IMG]http://i.imgur.com/L3Wn3zm.png[/IMG]
Very cryptic to me, google was useless. Also, I didn't seem to have this problem in my trivial little test program to figure git out.
EDIT: Before someone says, "just learn to use git normally", I've tried so hard, but it seems with git there is no abstractions, just a giant semi-consistent mess of commands geared towards experienced devs; I just can't do it.
EDITITED: Linus is doing a shit job of making me like him. Also, whoever was talking about VS 2012, if you're a student the professional version is free. Get it, it is awesome.
[QUOTE=DoctorSalt;39889398]EDIT: Before someone says, "just learn to use git normally", I've tried so hard, but it seems with git there is no abstractions, just a giant semi-consistent mess of commands geared towards experienced devs; I just can't do it.[/QUOTE]
I use TortoiseGit. It seems to be what you might want.
In Android Java:
How would one make it so it fetches specific data from SQlite dabatase, then prints it out in rows( each row has it's own id as it's different entry). And when user clicks on that item/row it will show menu: Remove, Edit, Cancel?
Any ideas?
Could someone explain in detail, preferably in OpenTK and if not explain it like I'm a total noob, how deferred rendering is accomplished?
I've got a basic 3d model renderer in C# and OpenTK and the last few days I've been trying to get deferred rendering implemented.
I've looked at a dozen of tutorials yet I can't seem to get something that works.
I'd very much appreciate it if someone could take the time to explain how it should be implemented from beginning to end.
If I'm filling values into a search three how the hell do I compare something like A123 with 4567? Which value is larger and why?
[QUOTE=Protocol7;39900183]If I'm filling values into a search three how the hell do I compare something like A123 with 4567? Which value is larger and why?[/QUOTE]
You choose
[QUOTE=esalaka;39900270]You choose[/QUOTE]
well I just wrote a C++ script to compare strings, and you can use assumptions so I'll just state that I treated the elements as strings so they could be compared bitwise
edit:
ergo B tree
[t]http://puu.sh/2h34h/eaa9102caf[/t]
obviously unfinished
e: idk this might be wrong
yeah lol I'm treating it like a BST not a B-tree
In what .cpp in a source mod can you modify a weapon's damage? I'm having no luck in locating the files.
[url]https://developer.valvesoftware.com/wiki/User:Daeval/Weapon_Basics#Functional_Properties[/url]
It seems that it's not defined in the C++, but in a txt file. (note, I'm pretty certain that servers have their own copy of that file, and it'll use that to calculate the damage dealt in Multiplayer)
For my CS1 class, we were assigned to write a game for our graphics unit. My partner and I are doing a simple 2 player pong game where each paddle is being controlled by up/down (paddle 1) and w/s (paddle 2). currently we're using:
[code]
private class Key extends KeyAdapter
{
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_UP && nK.getY() >= 0) //getY returns the current Y coordinate
{
nK.setY( nK.getY() -10); //nK is the first paddle. SetY sets the defined Y coordinate.
}
if(e.getKeyCode() == KeyEvent.VK_DOWN && nK.getY() + nK.getYWidth() <= FRAME2) // Frame2 is the Y Dimension of the window.
{
nK.setY( nK.getY() +10);
}
}
}
private class Key2 extends KeyAdapter
{
public void keyPressed(KeyEvent f)
{
if(f.getKeyCode() == KeyEvent.VK_W && sK.getY() >= 0)
{
sK.setY( sK.getY() -10); //sK is the second paddle
}
if(f.getKeyCode() == KeyEvent.VK_S && sK.getY() + sK.getYWidth() <= FRAME2)
{
sK.setY( sK.getY() +10);
}
}
}
[/code]
Our problem is that with getKeyCode, it only accepts the input of one key at a time, so if one person is pressing U and the other is pressing Up at the same time, the only paddle that moves will be the one last pressed (so if it is pressed in the order of U then Up, then only paddle 1 will move).
tl;dr, getKeyCode doesn't accept multiple key input. What do I do?
(comments are added because our teacher told us to to prove we know what the code does
[QUOTE=prooboo;39903921]For my CS1 class, we were assigned to write a game for our graphics unit. My partner and I are doing a simple 2 player pong game where each paddle is being controlled by up/down (paddle 1) and w/s (paddle 2). currently we're using:
[code]
private class Key extends KeyAdapter
{
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_UP && nK.getY() >= 0) //getY returns the current Y coordinate
{
nK.setY( nK.getY() -10); //nK is the first paddle. SetY sets the defined Y coordinate.
}
if(e.getKeyCode() == KeyEvent.VK_DOWN && nK.getY() + nK.getYWidth() <= FRAME2) // Frame2 is the Y Dimension of the window.
{
nK.setY( nK.getY() +10);
}
}
}
private class Key2 extends KeyAdapter
{
public void keyPressed(KeyEvent f)
{
if(f.getKeyCode() == KeyEvent.VK_W && sK.getY() >= 0)
{
sK.setY( sK.getY() -10); //sK is the second paddle
}
if(f.getKeyCode() == KeyEvent.VK_S && sK.getY() + sK.getYWidth() <= FRAME2)
{
sK.setY( sK.getY() +10);
}
}
}
[/code]
Our problem is that with getKeyCode, it only accepts the input of one key at a time, so if one person is pressing U and the other is pressing Up at the same time, the only paddle that moves will be the one last pressed (so if it is pressed in the order of U then Up, then only paddle 1 will move).
tl;dr, getKeyCode doesn't accept multiple key input. What do I do?
(comments are added because our teacher told us to to prove we know what the code does[/QUOTE]
[url]http://stackoverflow.com/questions/752999/how-do-i-handle-multiple-key-press-in-java[/url]
This seems like what you need.
[QUOTE=mobrockers2;39904056][url]http://stackoverflow.com/questions/752999/how-do-i-handle-multiple-key-press-in-java[/url]
This seems like what you need.[/QUOTE]
Correct me if I'm wrong, but those answers seem to be telling the author how to account for if and only if two keys are pressed (ex: the action wont be performed if you press ctrl and z at different times but only if you press ctrl+z at the same time). I need it so that it will work in all instances of the keys being pressed
[QUOTE=prooboo;39904120]Correct me if I'm wrong, but those answers seem to be telling the author how to account for if and only if two keys are pressed (ex: the action wont be performed if you press ctrl and z at different times but only if you press ctrl+z at the same time). I need it so that it will work in all instances of the keys being pressed[/QUOTE]
No, it should also be applicable to your problem.
[editline]13th March 2013[/editline]
I think.
Sorry, you need to Log In to post a reply to this thread.