C++ :: Array Char Rotation And Arrow Key Usage

Apr 27, 2013

I am doing a project for a class which involves making a game where there is an arrray that holds a player (you) and a zombie (comp). The player is suppose to be able to turn clockwise or counter clockwise, move forward, and backward and shoot. Im having trouble trying to rotate the char in an array. I am also trying to switch from using the W,S,D,A to the arrow keys but doesnt seem to work.

#include <iostream>
#include <windows.h>
#include "color.h"
using namespace std;
using namespace Petter;
const int COL = 15;
void initBoard(char[][COL], int, int);

[Code] ....

View 5 Replies


ADVERTISEMENT

C :: Make Rotation To 2d Array Without Using Any Other Array

Dec 7, 2014

which asking to make a rotation to a 2d array without using any other array , so here's an example :

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

i want to add 90 degree so :

13 9 5 1
14 10 6 2
15 11 7 3
16 12 8 4

View 2 Replies View Related

C++ :: Comparing Char Array To Char Always Returns True

Dec 23, 2014

I've made a code to check whether or not a save file has been created correctly, but for some reason it always returns this line: readdata[qa]=='1' as true. in which qa is the counter I use in a for loop and readdata is a character array consisting of 50 characters that are either 0, 1 or 2.

this is the entire code:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

[Code]....

at first is also went wrong at line 22 and also returned that as true, but then I added brackets and it worked.

View 4 Replies View Related

C++ :: Concatenate Two Char Arrays Into Single Char Array?

Sep 29, 2014

I am trying to concatenate two words from a file together. ex: "joe" "bob" into "joe bob". I have provided my function(s) below. I am somehow obtaining the terminal readout below. I have initialized my memory (I have to use dynamic, dont suggest fixing that). I have set up my char arrays (I HAVE TO USE CHAR ARRAYS (c-style string) DONT SUGGEST STRINGS) I know this is a weird way to do this, but it is academic. I am currently stuck. My file will read in to my tempfName and templName and will concatenate correctly into my tempName, but I am unable to correctly get into my (*playerPtr).name.

/* this is my terminal readout
joe bob
<- nothing is put into (*playerPtr).name, why not?
joe bob joe bob
seg fault*/
/****************************************************************/
//This is here to show my struct/playerInit

[Code]....

View 2 Replies View Related

C :: Char Array With A Phrase To Char Word

Nov 28, 2013

I need to do a function that copy every word from a text to a char word. How can i do it?

View 5 Replies View Related

C++ :: Dot Operator Versus Arrow

Jun 26, 2014

I understand that the dot operator is:

Code: a.b "a"

is the actual object (not a memory location) and "b" is the member. I also understand the arrow to mean:

Code: a->b "a"

is a pointer to a struct and "b" is it's member so "a" is dereferenced then "b" is given.

Here is where I get a little confused. I have a class:

exampleclass.h
Code:
#ifndef EXAMPLECLASS_H_INCLUDED
#define EXAMPLECLASS_H_INCLUDED
class exampleclass{

[Code].....

Also if ec1 had a public variable and I wanted to access it would it be referenced the same way as the method I call in ec1?

View 4 Replies View Related

C :: AVL Left And Right Rotation

Feb 7, 2013

I am creating and implementing a left and a right rotation to balance a bst into an avl tree. I have made and tried 5 different codes that are commented in the functions left_rotate() and right_rotate() but none have run correctly. Sometimes the program works, sometimes there is a segmentation fault and sometimes not all inserted numbers are shown.

avl.c

Code:
#include<stdio.h>#include<stdlib.h>
#include<time.h>
#include "avl.h"
#define N 10
void swap(int *a, int *b){

[Code] ....

View 1 Replies View Related

C :: How To Make A Menu That Uses Arrow Keys

Feb 12, 2015

My program uses a menu that easily facilitates a person to navigate trough out it but im stuck on a part and I cant go to menu3 with the arrows (only use c code not c++)

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
void sleep(long int interval) {
for(int i=0;i<interval*1000;i++);}

[Code]...

View 6 Replies View Related

C :: How To Create Menu Selection With Arrow Key

Jun 22, 2014

I'm looking for an example of menu selection with arrow key i'dont know how to create one o think i should use CODE ASCI but what method I should follow

View 1 Replies View Related

C++ :: Visual Arrow Following Motion Of Ball?

Aug 25, 2013

I have created plane as floor and sphere as ball. I used physics equations to it and ball falls under gravity. Now i want to attach visual arrow to this ball which moves with it according to velocity direction. If ball bounces then direction of velocity is changed so does arrow.

View 1 Replies View Related

C# :: TextBox Navigation Using Arrow Keys

Mar 2, 2014

So I have assigned this method to each TextBox. It works fine pressing the left arrow and right arrow, but for some reason will not work using the up and down arrows. I have tested the string, using MessageBox and it is correct...the loop even proves it finds a matching TextBox. It is correct as in it displays the TextBox name it should be selecting but doesn't. I have no clue! Now the first select method is the one I want to use, I used the loop to check to see if it was even finding a match. It does find it but doesn't select it. The naming convention for my text boxes is r1c1 where the first number indicates the row and the second number is the column. There are 9 rows and 9 columns. This SHOULD be working but for whatever reason it is not. I've even put a message box inside the if statement for the up and down keypress check and it pops up when i press up or down.

private void Navigate(object sender, KeyEventArgs e) {
TextBox input = (TextBox)sender;
string nextBox = input.Name.ToString();
if (e.KeyCode == Keys.Left) {
if (int.Parse(nextBox.Substring(1, 1)) > 1 && int.Parse(nextBox.Substring(3, 1)) == 1)

[Code] ....

View 7 Replies View Related

C Sharp :: How To Detect Whenever Down Arrow Key Is Pressed

Jun 3, 2012

So, I've been working on a project recently, and the only thing remaining to do is a detector to whenever down arrow key is pressed. The down arrow key can only trigger when a certain check box is checked and this will have to work with a timer either. The problem is that how to make the down arrow key press detector(I've got the check box and timer ready tho).

View 10 Replies View Related

C++ :: Detect Arrow Key Press For Linux Only

May 13, 2012

I'm trying to implement this on ubuntu, to compile and run only under ubuntu.

I found 100s of other attempts at answering the general question of arrow key press in c++. Nothing solid.

Some recommend using the Readline for the functionality I am trying to implement, but I need to stay clear of GNU licences if I can for this project. And some tips only work on projects for windows machines... for example the conio library.

For linux there may be the option of using the ncurses library which I will take a look at, but I am stubborn and want to implement this myself. It should be an easy straight forward thing to do, which is why I am a bit frustrated at the moment.

Here is my test code so far.

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;

[Code] ....

So! This works... 80% of the problem is solved. If you compile this, g++ under linux, ubuntu in my case, and run. Each keystroke reveals the correct key numbers.

q=113
w=119

when I click on the up key I get,

up = 279165

I thought, I can use this number is a if(int == '279165') to detect the up key.

I was not so lucky... this int is not behaving like an int!

So I modified the code to see it I could carry out an int operation on this number.

I added a 100000 to int i.

cout<< i + 100000;

Code:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;

[Code] .....

Compiling and running this, and pressing the UP key gives the following number.

100027100091100065

Some some sort of array, something like, [27][91][65].

I tried all ways to access these individual numbers, actually the third one for comparison purposes, but no luck.

For completeness sake I list the other arrows.

UP = [27][91][65]
DOWN = [27][91][66]
LEFT = [27][91][68]
RIGHT = [27][91][67]

A little further digging shows that these numbers are derived from the representation of a "multi-char" constant, the data type given when pressing special characters...

Now here is the main problem I have, I can find ANY decent documentation on how to handle and play with "multi-char" .

View 4 Replies View Related

C :: Image Rotation Without Cropping

Nov 4, 2014

I am new to image processing..... and I am learning the concepts.

Recently I have done image rotation of grey scale image using the following formula:

x' = xcos(theta)-ysin(theta)
y' = xsin(theta)+ycos(theta)

The problem i have faced is image is getting cropped.

I want to rotate an image without cropping. I have searched a lot but I am not getting any algorithm based on C. How to get the algorithm for image rotation without cropping.

View 2 Replies View Related

C :: Double Use Of Arrow Operator With Pointer / Function

Feb 24, 2015

I have recently come across a function call that I do not understand. It uses the arrow operator for a function call, twice, and I don't understand.

Code:

static inline void b43_write32(struct b43_wldev *dev, u16 offset, u32 value)
{
dev->dev->write32(dev->dev, offset, value);
}

I see that the function itself does not return anything but calls another function. The main difficulty I have is with the "dev->dev->" operator, where dev, I expect is a pointer to a structure.

View 8 Replies View Related

C++ :: Visualizing 3D Rotation Using Quaternion Data

Jun 10, 2014

Just bought a new ST Micro iNEMO-M1 system, and am looking to have my code visually show me the rotation information. I've got a working C++ code which actively acquires data from the sensor, and I'm looking to extend that into some visual interface which will show me on-screen the position of the sensor.

I figure using rotation information in the form of quaternion data is the most useful (want to avoid the gimbal lock problems associated with Roll/Pitch/Yaw).

What would be the best method to visualize the rotation of my sensor in real-time?

View 2 Replies View Related

C# :: Vertice Location After Quaternion Rotation

Aug 16, 2012

I have a 3d Point in space. From this point I have vertices defind by(scale). I have a Quaternion representing the rotation of the object (lets say a block). So...

(1) I know the point in local and world space and can translate.

(2) I know the scale of the object and it's starting vertices intersections at zero rotation.

(3) I have the quaternion which represents the 3d rotation and can translate that to degrees and Eulers.

How do i find the exact points of the vertices after the rotation. (what I'm attempting to do is plot points from vertice to vertice all along the sides/top/bottom of the object.)I have looked at Matrix4 transformations and Quaternions and still do not understand how to find the vertices after rotation.

View 8 Replies View Related

C++ :: How To Move Sprite Depending On Rotation

Jan 13, 2015

how I want my sprite movement to work: if my sprite is faced upwards and i press W, it will move up. If my sprite is faced to the right and i press W, it will go right. etc. // It doesn't work like that right now and how to do it.The sprite's rotation works fine.

if(sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) {
playerSprite.rotate(-0.08 * dt);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::E)) {
playerSprite.rotate(0.08 * dt);

[code]....

My question is how do I move the character depending on the rotation?

Also, you might see the "if(havePlayersCollided == false) {playerSprite.move(yadiyada)}" . yes i dont need the haveplayerscollided function because it doesnt work the way I want it to. I might make a thread for it in the future, but right now I need to get the rotation movement fixed before I move onto the collision detection between players.

View 7 Replies View Related

C++ :: Getting A Point Rotation Or Normal From 4 Vectors?

Dec 31, 2014

I'm trying to get a rotation of a spefic point in a 3D space using 3 or 4 coordinate/vector.

For example, I want to know the rotation of (5,5,5)

Using 4 vectors for example (0,0,0), (10,10,10), or 10,0,10, etc. (3 minimum)

View 2 Replies View Related

C++ :: Finding Rotation Direction From Two Orientations?

Mar 4, 2014

It is technically not a programming question and is more maths oriented. It has to do with game AI and specifically getting the AI to rotate correctly. I am trying to create the base method that handles AI rotation. It will take a target orientation and rotate the entity from it's current orientation to that target orientation.

Let's say we have a Entity that has the orientation of 1.57079 Radians (90 Degrees) and we want to change that Entity's orientation to 0 Radians (0 Degrees). How would one find the correct way to rotate from just them two orientations (IE find the shortest rotation direction from a current orientation to a target orientation)?

As my implementation stands now the Entity rotates just fine I think but always in a clockwise rotation (Because I can't figure out how to determine the best rotation direction). For example using the previous number (1.57079 Radians to 0 Radians) the Entity will rotate all the way around 270 Degrees clockwise instead of rotating just 90 degrees counter-clockwise.

I have thought about possibly projecting vectors a short distance forward from the current orientation and target orientation to figure out the rotation direction but not sure if that is a good way to implement it.

View 1 Replies View Related

C# :: Image Rotation Leaves Null Areas

Jan 29, 2015

I am working on a Paint program and I have a nice routine (copied from the Net) that beautifully rotates my Image by any chosen degree, and even preserving the entire Image with a 'noclipping' option.

The problem is - That after the rotation, say 45degrees, the areas in the corners, that originally were not part of the Image, cannot be drawn to. I have an 'eye dropper tool' that shows these areas to be null, having no color. My drawing tools will not work on these areas.

public static Bitmap RotateImage(Image image, float rotateAtX, float rotateAtY, float angle, bool bNoClip) {
int W, H, X, Y;
if (bNoClip) // use Clipping {
double dW = (double)image.Width;
double dH = (double)image.Height;
double degrees = Math.Abs(angle);

[Code] ....

View 13 Replies View Related

C++ :: Print In Asterisks Oval / Arrow And Diamond Using For Loop And If Statements

Jan 15, 2015

#include <iostream>
using namespace std;
int main(){
return 0;
}

this is my main functions. I have problem making a program that prints in asterisks an oval, arrow and a diamond using for loop and if statements.

View 1 Replies View Related

Visual C++ :: Detect And Find Rotation Angle If Skeleton Tracked Turned 180 Degree To Kinect

Sep 25, 2013

I m developing an application using kinect.The IDE I use is Visual studio 2012 and kinect SDK 1.8.I m developing using vc++

I want to overlay an image on the person tracked when the person turns 180 degress to kinect. ie the person is not facing the kinect.

how do i track the rotation angle of the person as he/she turns away from kinect.

View 7 Replies View Related

C :: Static Variable Usage

Dec 27, 2013

I was exploring static variable by writing code snippets. I tried below code and it ended up throwing error saying "error: storage class specified for parameter 'b'"

Why static cannot be used in func() ?

Code:
int main() {
int a;
a=5;
func(a);
printf("%d",a);
return 0; }

void func(static int b)
{b=6;
printf("%d",b); }

View 7 Replies View Related

C :: Vector Usage In Codes

Sep 19, 2014

Now i am utilizing vectors in my codes.If i want to make a vector and i use #define to put a limit on the amount of variables it can contain. Until now i can do that. But let's suppose that i put 40 variables as its max capacity, but an user just needs to use only 12 or 14 variables. Put a rule that if someone has finished inserting his data and he is yet to fill the whole capacity of the vector the code.As to say : "If case you want to end press 0" .Edited : My computer has windows 7 and i took Codeblocks as my editor.

View 2 Replies View Related

C++ :: Check CPU / RAM USAGE / Temperature

Nov 1, 2014

I want to make an application that will check CPU/RAM USAGE and CPU TEMPERATURE and if it meets some requirements it will restart your system or do something else..but my problem is:

1) How do i get that info? (i know that in VB.net there is an easy way) but in C/C++ or Java?

2) Is it possible though a C program to execute a command and parse that info to your program?

I am mainly interested for windows but i need also info for linux too..

View 4 Replies View Related







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