C++ ::  How To Move Characters On Screen Using Keyboard

Dec 3, 2013

How to move a character (an arrow or any other character) on screen using keyboard? I'm actually a beginner and have only wrote simple (starter's) programs in C++. It would be great without using any external library which is not included in C++ by default (in other words, using plain C++).

View 8 Replies


ADVERTISEMENT

Visual C++ :: On Screen Keyboard Error On 64 Bit Windows 7

Dec 6, 2013

By using visual studio 2010, I have problem calling up on screen keyboard using line below for Windows 7 64 bit.

WinExec("OSK.EXE", SW_SHOW);

However, it is working fine on windows XP 32 bit. How to call up on screen keyboard for 64 bit windows?

Code:

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) {
int nRetCode = 0;
HMODULE hModule = ::GetModuleHandle(NULL);
if (hModule != NULL) {
// initialize MFC and print and error on failure

[Code] ...

View 2 Replies View Related

C/C++ :: Game Of Fifteen - Swap Move Not Showing On Screen

May 26, 2014

I am having problems with my game of fifteen. I have implemented the swap> I know the swap takes place[using GDB] but the swap does not show on the screen even if GDB says it has taken place. I am getting no errors from the move function so I know that something is taking place. I was thinking that the problem may be in the draw function but it looks okay to me. I have looked at this over and over but I don't know why the draw is not printing the move to the screen.

#define _XOPEN_SOURCE 500
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// board's minimal dimension
#define MIN 3
// board's maximal dimension
#define MAX 9

[Code] ....

View 14 Replies View Related

Visual C++ :: Draw Multiple Lines And Move Them On Screen

Jul 28, 2013

I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.

I have created rectangle region for each line and trying to move the line.

When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.

How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC.

View 4 Replies View Related

C/C++ :: Program That Read A Number From Keyboard And Print Separated Digits To Screen

Feb 18, 2015

Basically this is what i need to do. Write a program that reads a number from the keyboard, separates it into its individual digits and prints the digits to screen, each on its own line followed by the same number of stars as itself.

For example, if the number is 2339 the program should print

9 *********
3 ***
3 ***
2 **

So far i have managed to separate the number and have them on different lines, but how to implement the stars onto each line with the number!

My code so far:

int main() {
int n;
printf("number? ");
scanf("%d", &n);
while (n > 0) {
printf("
%d

[Code]...

View 4 Replies View Related

C++ :: Keyboard Function That Is Called In Main Function To Make Shape Move

Jan 19, 2013

Ok so I am working on a game and I'm in the process of developing my Player class. Anyways, what I have is a keyboard function that is called in my main function to make a shape move.

void myKeyboardFunction(unsigned char key, int x, int y) {
switch ( key ) {

[Code].....

But when I try to call it, trying to copy my previous method,

glutKeyboardFunc(Player1.playerControls);

I get an error

error C3867: 'Player::playerControls': function call missing argument list; use '&Player::playerControls' to create a pointer to member

I get an error saying it can't convert parameters. I would just like to understand why the arguments become a problem when I make the function a member of my class, when the first method I used is so easy.

View 2 Replies View Related

C++ :: Pacman Game - Move Smiley In Code Automatically And Stop Screen Flickering?

Dec 26, 2013

So far I have managed to write the code for a simple game (resembling to "Pacman") :P. Now what I want is to move the smiley in the upper left-hand corner of the map "automatically" when the program runs and also want it to change it's direction to up or down when it touches the wall.

Also the screen is flickering when the program runs (due to re-printing the whole array?). I want to stop this flicker. Somebody suggested to use 'gotoxy' function.

Here's my code :

#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;
void display (char array [10][25] , int row , int column) {

[Code] .....

View 8 Replies View Related

C++ :: How To Implement Lexicographic Order Of Some Characters Entered From Keyboard

Jul 28, 2014

I want to implement a lexicographical order of some characters entered from the keyboard. when i press "n" i want it to return the order. Ignore the part with "insert a specific number of words" that's for smthn else.

#include <iostream>
#include <string.h>
using namespace std;
int main () {
int n, i, j;
char oprire, decizie, v[20], x[100][20];

[Code]...

it keeps giving me returned error code -1073741819

View 2 Replies View Related

C/C++ :: Recursive Function To Move Specific Characters To End Of String?

Oct 16, 2014

I am attempting to write a recursive function that, given a string, recursively computes a new string where all the lowercase 'x' chars have been moved to the end of the string.

For example,

moveXs("xxre") --> "rexx"
moveXs("xxhixx") --> "hixxxx"
moveXs("xhixhix") --> "hihixxx"

Below is the code I have written thus far, but it seems to be returning only empty strings.

string moveXs(const string& str) {
string strCopy = str;
if (strCopy.length() <= 1) {
return str;

[Code] ....

View 6 Replies View Related

C++ :: Ncurses - Highlighting A Line Of Characters On Screen

Oct 25, 2013

I am writing a program using ncurses that needs a function to highlight a line of characters on the screen. I started writing this function that took the x & y coordinates of a character on the screen and the length of characters after that to highlight. Whilst doing this I noticed that if I highlighted the last character in a row (maxX-1 in my example) it highlighted that character (as expected), and if I highlighted just the character before that (maxX-2) it also works. But if I do both, it highlights the whole row/line. Also, if there are characters in those spaces other than the 'space' character it works too, but for my program I need to be able to highlight empty spaces as well.

To highlight I am using inch() to get the character and addch() to print it because I am using some alternate characters that chgat() replaces with normal characters.

#include <ncurses.h>
int main(){
initscr();
start_color();
use_default_colors();
curs_set(0);
noecho();

int maxX=0, maxY=0;

[Code] ....

View 3 Replies View Related

C :: How To Print Characters But No String Just Array Of Characters

Mar 20, 2014

so my question is i want to print characters,no string just an array of characters,i do this but it s not working,maybe i have to put the '' at the end?

Code:

int main() {
int i;
char ch[5];
for(i = 0; i < 5; i++) {
scanf("%c",&ch[i]);

[Code]...

View 6 Replies View Related

C/C++ :: Find The Common Characters Between Two String Characters

Jul 6, 2014

Im supposed to find the common characters between two string characters, assuming that the user wont input duplicate letters like ddog. When I run my code I get an output of a question mark upside down. Here is my code with comments on what each part is supposed to do

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char str1[20], str2[20],remp = '';
int size1,i,j,temp;
printf ("Input the first string");

[Code]...

View 6 Replies View Related

C/C++ :: Check For Set Of Characters In Array Of Characters?

Mar 26, 2014

I have an array of characters. I am trying to find "houston". The only way I can think of to do this is to use a for loop and check each individual character. Is there an easier way to do this?

char string[] = "Fishing tourism miami atlanta dallas houston";

View 9 Replies View Related

C :: Capturing Keystroke From Keyboard

Jun 11, 2013

I want to intercept key to my program even if it is non active. I'am working on linux machine(ubuntu)..what should i use to do this?

View 6 Replies View Related

C :: Program Respond To Keyboard Hit?

Mar 6, 2015

What C command responds to a keyboard hit? I want to exit in an orderly manner from a continuous loop when a key is pressed.

View 5 Replies View Related

C :: How To Ignore All Key Presses On Keyboard Except 1-5

May 7, 2014

Here is the function I am trying to modify...

Code:
void DisplayAdminMenu() {
char ch;
system("cls");
printf("Admin Menu");

[Code] ......

Error! Must enter a number between 1 and 5

View 6 Replies View Related

C :: Run Some Operation If A Key From Keyboard Is Pressed

Jun 2, 2013

I need to run some operation if a key from keyboard is pressed. so I go with

Code: c=getchar();

to get it read. yet the user could press a key anytime; so I'd need some if-loop. no plans on how it'd look like though...I suppose something like this below wouldn't work right?

Code:
if(getchar()==1){
..
}

View 5 Replies View Related

C++ :: How To Allow Pressing Some Keys On Keyboard

Jul 4, 2014

how can I allow pressing some keys on the keyboard in C++? I mean, when you are in the console and you are only allowed to press numbers before pressing enter, for example.

View 6 Replies View Related

C++ :: Read A String From Keyboard

Mar 27, 2013

char name[10];To read a string from keyboard.

what should i use :

this : cin>>name[10];
or
this : cin>>*name;

View 3 Replies View Related

C++ :: SDL - How To Get Keyboard Input Into Function

Aug 31, 2013

I am trying to get my keyboard input into a function, so that I can call a function like updatebuttons() and set global variables to 0 if the button is not down at the moment and 1 if it is. It seems simple, but I can't seem to get it to work right; I am not use to working outside of windows, so I am still a beginner with SDL.

View 4 Replies View Related

C++ :: Connecting Event With A Key On Keyboard?

May 17, 2013

I am gonna make a simple game in c++. I need a way how to use a particular key on the keyboard ,when I hit the key certain function should be called.

For movement of cursor on screen I want to connect arrow keys.

View 4 Replies View Related

C++ :: Move A Character Around 2D Map?

Mar 3, 2013

How can I move a character around a 2D map? After some research and a bunch of work I made a function for movement:

unsigned int gamespeed = 100;
unsigned int stage = 1;
void controls()
{

[Code]....

Maps are stored in a different .cpp file

So this code works, but is complicated, ugly and evil (I have to make a pointer to the first map and change the pointer to the next map every time the user reaches the exit, without the pointer this code is, of course, incompatible). How can I reduce this code to be less evil/ugly or at least smaller?

Also it would be nice if the user could move around with arrows as well as with WASD

View 5 Replies View Related

C :: Initialize For Loop Using Input From Keyboard?

Feb 22, 2015

I'm not finished with this code, but I am stuck on this one glitch. This is what I have so far, and it's not working.

Code:
int main() {
/*Please input an n value greater than zero. Otherwise, exit the program by entering a carriage return*/
printf("Please input an n value greater than zero. Otherwise, exit the program by entering a carriage return
");
int summation = 0, x, y;
scanf("%d", y);
for (y == x; summation <= M_E && x <= 34; x++)

[Code] ....

View 1 Replies View Related

C++ :: How To Take Input From Keyboard Using Fgets And Atoi

Oct 12, 2014

Intead of using scanf("%d",&a) to take a input from the user,how to take a input using fgets(buffer, BUFFERSIZE , stdin) and atoi?

View 1 Replies View Related

C# :: How To Add Keyboard And Button Press To A Program

Apr 13, 2014

I have a problem where I need to add the ability to input numbers into a calculator program through either a form button press or keyboard press. I have the button press working fine though I can't seem to get the program to start with the cursor active in the textbox for keyboard input. I've use this.ActiveControl = result; "result" being the textbox. Though the issue here is the program starts off with the cursor active but only for the first instance of keyboard inputs.

Perhaps its the way I wrote the program but is there a way I can achieve this? I found a way to write this calc by having a single event for all button presses, opposed from an event for 1-9. Not sure if this is a good approach but here is some of the code.

private double num = 0;
private string calculate;
bool pressed = false;
private void button_Click(object sender, EventArgs e) {
if ((result.Text == "0")||(pressed == true)) {

[Code] ....

View 1 Replies View Related

C++ :: Can't Get Program To Move Forward

Feb 24, 2014

After I enter in the 8 digit account number the program just stops and I can't find where the logical error is

Code: #include <iostream>
#include <iomanip>
#include <string>
using namespace std;
bool validateLength(string);
bool validateDigit(string);
void calculateA(string);
void calculateB(string);
void calculateC(string);
bool validateService(string);

[code]......

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved