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


ADVERTISEMENT

C++ :: Visual Studio 2013 - Leap Motion Virtual Piano

Sep 10, 2014

I currently have a project that requires me to build a leap motion Virtual Piano. I am using Windows Visual Studio 2013 and i plan to use C++ to code it.

I assume my first step is to create a virtual piano using C++.. Then, link it with leap motion interface.

Can i know which audio library suits my project and how can i go about doing it?

View 1 Replies View Related

C/C++ :: Spin A Ball Around The Roulette

Mar 12, 2014

As you can see my code runs fine but I have a small problem. I am trying to spin the ball around the roulette but the ball appears 37 times instead of 1. I want only one ball to spin around and not 37.

#include <math.h>
#include <gdfontg.h>
#include <stdio.h>
#include <stdlib.h>
#include <gd.h>
#define USE_GLOBAL_COLORMAP 1
#define USE_LOCAL_COLORMAP 0

[Code] ....

View 7 Replies View Related

C++ ::  How To Move A Ball Continuously In 2D Scrolling Game

Dec 29, 2013

The situation is , I have a ball which should move on a flat horizontal surface which i have created in a display of 800 x 400 . Right now!I am able to make it move left or right in direction using key inputs at a fixed speed.

But I want to make it move horizontally at a constant velocity without using keys. Like in copter game.

It should be able to move automatically , towards the right side.

Increment x position by speed variable does the trick but When I used it with keys I used to limit the movement like.

ball.x += ball.speed;
if(ball.x > 750)
ball.x = 750; // because my screen width is 800.

[URL] .... < this video will show what I really want to do with the ball

If you saw the game video in the link i gave, the ball kept moving with constant velocity. But it never went out of bound. What is keeping it from not getting out of display screen. Instead! its moving continuously... but stays almost at the center of screen. How?

View 7 Replies View Related

C++ :: Ball Collecting Game - EXE Not Running Outside Code Blocks

Apr 13, 2014

I have created a game.It is working fine in codeblocks, but when I am trying to run it outside codeblocks, it opens and closes immediately. I have pasted all the necessary files and dlls in root folder and debug folder. Here is the code:-

#include <iostream>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <sstream>

const int WINDOWS_Height = 480;
const int WINDOWS_Width = 640;

[Code] .....

View 2 Replies View Related

C++ :: SDL - How To Handle Mouse Motion Input

Oct 19, 2013

I am using SDL 2.0. But I don't know how to handle mouse input. Do you think you can explain of how to do that? Or give me a link that explains that really great?

I know how to handle a mouse button that presses down for a sec.

Code:
if (event.type == SDL_MOUSEBUTTONDOWN){
if (event.button.button == SDL_BUTTON_LEFT){
// Do something . . .
}
}

But not how to handle the mouse input of what the mouse is hovering over and that.

Like in a start menu of a game. I want a button for example to appear blue when I hover over it and when I click on it. It should start the game for example.

View 6 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/C++ :: Trapezoidal Motion Profile Using Discrete Method?

Mar 9, 2015

I'm trying to program an arduino to generate a Trapezoidal Motion Profile to control a DC motor with a quadrature encoder.

Essentially, the user will input the desired Target Position, Max Velocity and Acceleration (decel = -accel) and the code will calculate the target position versus time which will then be compared with the actual position. The result will then be subject to a PID calculation

My initial assumption was that I could use basic Newtonian physics to determine position (i.e. PT = P0 + V0T + 1/2AT2, VT = V0 + AT). However, after reading through documentation for pre-existing motion controllers, I discovered that the prevalent method was to use a discrete time method, which is as follows:

VK = VK-1 + A (A = Acceleration)
PK = PK-1 + VK-1 + A/2

I'm having a hard time understanding quite how this equation would generate the target position versus time. In the case of Velocity, it seems to just add the acceleration to the current velocity. But what about everything in between?

View 2 Replies View Related

C# :: How To Make A Planet That Moves In A Circle Motion

Dec 7, 2014

i would like to make a planet that moves in a circle motion. I dont know how to start and how i can move a "planet" in a circle motion?

View 2 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# :: 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 :: Arduino Programming - Control Motion Of Servo Motor

Jul 16, 2013

I am working on a project that requires using an arduino microcontroller to control the motion of a servo motor. The arduino language is pretty much C.

The original code is of the form:

Code:
#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

[Code] .....

But the problem is I don't want the motor's motion to behave linearly (constant increments of the pos variable). My desired motion is a sinusoidal like function. How to approach this?

I am quite new to programming, especially with microcontrollers. My guess is that instead of the pos+=1, I would need something like pos+=sin(argument). I am not sure what that argument should be.

View 4 Replies View Related

C++ :: Simulation Of Motion Of Magnets On A Rod - Long Double Not Working

Apr 25, 2013

I'm currently working on a simulation of the motion of magnets on a rod. As part of it, there are arrays of the properties of the magnets:

long double *accelerations; // These will later be dynamically allocated depending on the number
long double *velocities; // of magnets
long double *positions;

However, when I go to compile this, the compiler gives me these error for the pointers:

error: two or more data types in declaration of 'accelerations'
error: two or more data types in declaration of 'velocities'
error: two or more data types in declaration of 'positions'

Apparently, the compiler isn't recognising long double* as a type and is instead reading is as the two types long and double*.

My compiler is MinGW 4.4.3

View 4 Replies View Related

C Sharp :: Motion Of Controls - Picturebox Position In Form?

Apr 8, 2012

I have a form with a picturebox and some buttons to move the picturebox. I don't want the user to guide the picturebox out of the form even by dragging the form border picturebox moves just in the form border, and also there is a button to guide the picturebox to the start position (start choose by user). What can i do?

View 1 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++ :: 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 View Related

C Sharp :: Full Code For Webcam Alert Motion Detector?

Mar 12, 2013

i have webcam i need to make project when this webcam detect any motion in his spot give me alert ,,,

View 4 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++ :: PIC To PC Using MFC Visual Studio Through Serial Communication

May 28, 2014

The project is about reading data from PIC and display the data on the dialogue created by the MFC GUI of Visual studio 2010. There are 4 data need to be displayed (2 weight and 2 angle). the data will be display on the edit control box on the dialogue.

I have try to solve the COMPort and Readdata issues many times, but I'm fail. I have read many sources and implement the source codes... They are never work....

The detail about the issues that I need to solve is clearly mentioned on the main dialogue.cpp. Take a look to an uploaded zip file that I have attached.

View 6 Replies View Related

Visual C++ :: Cannot Seem To Set Var

Nov 8, 2012

What I'm trying to do is get the selected folder value put into my dirlocation var.

Code:
private void dirLocation_Click(object sender, EventArgs e) {
FolderBrowserDialog fdb = new FolderBrowserDialog();
fdb.Description ="Please choose the directory your .rlt files are located in";
if (fdb.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
dirLocation = fdb.SelectedPath;
}

Is this how you do it? I keep getting an error like Cannot implicitly convert type 'type' to 'type.

View 5 Replies View Related

C++ ::  How To Use QT With Visual Studio

Aug 15, 2014

I heard that you can't use it with express, but that doesn't seem right... Can you use it with Codeblocks, at least? I just hate the Qt Creator IDE. I don't like the UI... all I want to do is code Qt. I don't care much for the GUI editors.

View 10 Replies View Related

Visual C++ :: Create MFC OCX Using DLL

Aug 28, 2014

I am trying to create a OCX from a C++ dll., Here's the scenario I have a C++ dll and this dll needs to be called in VB.net program my boss want's me to create an OCX out of this.

C++ dll and use it in a VB.net class library, apparently I have created an OCX but it requires a form but the VB.net program is a class library.

View 5 Replies View Related

Visual C++ :: How To Convert IP To Hex

Sep 27, 2012

I don`t known how to convert IP to hex .

In this link [URL] .... . I see hex IP : Hex IP 0x462a1779

I want to convert IP "70.42.23.121" to "0x462a1779"

Code:
#include <winsock.h>
#include <windows.h>
#include <stdio.h>
UINT32 ip_to_hex(UINT32 ip_add) {
UINT32 ip_hex;
//code convert ip to hex
return ip_hex;

[Code[ ....

And this is result : 7b 1e 80 and a , not 0a

Further i think we must separate each octect by a (dot) . , Then convert decimal to hex.

View 6 Replies View Related







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