C++ :: Moving Object In Array
Nov 30, 2014
I want to make an object in array[][] move
Ex:
array[2][5]
array[0][0] = 'O'
O| | | | |
| | | | |
| | | | |
then
|O| | | |
| | | | |
| | | | |
then
| |O| | |
| | | | |
| | | | |
......
how can i print my array in console then change&print it again, then change&print it again,... So it look like O is moving
???
View 1 Replies
ADVERTISEMENT
Sep 22, 2013
I want to make an object, which moves from x1,y1 to x2,y2 in a straight line, also make a sinus over the line (so the x,0 is the line itself, and cux,cury is the object. So the object will move as a sinus over the line. How do I do this in c++?
View 3 Replies
View Related
Jun 13, 2014
i want to make moving button or moving box clickable as i am making a game in which i move picture boxes and user clicks on it and his scores increases. but i was unable to do so , so i tried the same concept with buttons but no results.
View 7 Replies
View Related
Feb 27, 2013
I have a multidimensional array that runs parallel with a string array
Lincoln 120 300 400
Parks 100 500 250
Shakespeare 0 30 50
Ghandi 250 100 40
Ashe 300 50 175
Rodriguez 87 118 320
Curie 284 0 112
I need to sort this and I know how to do it. But I need to sort it again with the highest value in the first row and keep all information in that row paired with the name . So
Lincoln 120 300 400
Parks 100 500 250
Parks 100 500 250
Lincoln 120 300 400
I need so swap this whole rows. I'm using dynamic array. So my question is Do I have to do a bunch of temps to move them? Or is there a way to move the whole int array row as a single unit?
View 3 Replies
View Related
Mar 19, 2014
Basically, my function receives an array. For example:
u8 array = {1, 2, 3, 4, 5}
I don't need the first 2 elements, how can I access the array's 3rd element as head? I plan to throw the received array to another function.
array = array[2];
somefunc(array);
Will somefunc get index 2 as start of the array?
View 1 Replies
View Related
Dec 20, 2013
im trying to get my array to display 5,1,2,3,4 from the original 1,2,3,4,5.
void values::movevalues()
{
cout << "postcondition
";
[Code]....
something in this part is making it go wrong, it displayes the original array fine but when it tries to shift it it goes haywire. EDIT: also how would i add elements onto the array?
View 10 Replies
View Related
May 21, 2013
This is for a class project. I am having trouble "pulling out" the last element in my array, shifting all the elements back then inserting that last value in the front. Then also displaying the array after the shift. here's my code.
#include "stdafx.h"
#include<iostream>
using namespace std;
[Code].....
View 3 Replies
View Related
Mar 19, 2013
URL.....Now, I am trying to model "light" inside the world[20][20] char array by using a char light[4][4] which only opens up the map in enclosed in the light area of effect. In this case 4x4. I have tried quite a few things, including 4Darrays, but nothing comes close. Essentially, I want to be able to move the light[][] array freely inside the world[][] array centered at some arbitrary point.
View 2 Replies
View Related
Sep 22, 2014
I'm trying to figure out how I can create a vertex array object at offset of a vertex buffer object.I've created the buffer object. I'd like the "texs" idnex data to start at the texture coordinate content of the vertex_t structure.
Type definitions:
struct vertex_t {
vector3d_t position;
float s; // Texture coordinate s
float t; // Texture coordinate t
};
Code so far:
// How do I make this start at a certain spot of the VBO?!
glVertexAttribPointer(texs, 2, GL_FLOAT, GL_FALSE, sizeof(vector3d_t), nullptr;
//...
View 1 Replies
View Related
Feb 18, 2015
I have a character at a co-ordinate, say (3,4) for example, and I need to get him to (10,15). I would like him to move one block every tick or half a second, so that you can see him moving towards his destination. How to achieve this?
View 3 Replies
View Related
Apr 15, 2014
I'm making this program to mess with people and make them think its a virus.
#define _WIN32_WINNT 0x0500 //For hiding your console
#include <cstdlib>
#include <iostream>
#include <Windows.h>
#include <WinBase.h>
[Code]....
At line 42 and 43 I want to make the cursor move around in a circle over and over again but I'm not sure how.
View 4 Replies
View Related
Apr 28, 2013
I have a board where a character is. I need to ask the user whether they want to move it up, down, left right. They are allowed to enter 3 move per turn. like up, up, left. How do I do this?
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int COL = 17;
const int ROW = 17;
[Code] .....
View 3 Replies
View Related
Nov 1, 2013
I'm trying to serialize and deserialize objects, some static (that works) one moving (doesn't work). In the code you can see that the following int-variables discribe the moving circle:
object->phaseFarbe=phase1;
object->phaseKoord=phase;
object->rot=a;
[Code].....
View 1 Replies
View Related
Jan 6, 2015
I am making a game and I am attempting to get the zombies to move randomly but for the life of me, I simply don't have the knowledge with srand to do it
#include <iostream>
#include <windows.h>
#include <time.h>
[Code].....
View 13 Replies
View Related
Jan 12, 2015
The question says:
Place an Image on top of a Button. Move both when the Button is pushed.
It's here [URL] exercise no.3
look at this code:
#include <GUI.h>
using namespace Graph_lib;
//------------------------------------------------
class rotation : public Window {
public:
rotation(Point xy, int w, int h, const string& title):
[code]....
The problem is that, it is not possible to define an Image in public/private part of the class rotation. Image needs all arguments to be supplied even when declaring one. (Image is here [URL] And if I define that Image in the body of main() function, so how to provide access for void rotate() to change its position with the position of button simultaneously.
View 8 Replies
View Related
Feb 9, 2013
I am not so experianced with c++ myself, but I need to evaluate if a certain idea might work.
I am working with a system for automation purposes that is running on a realtime OS in parallel to windows. Windows and the RTOS exchange data via shared memory. The application in the RTOS is compiled in C++. Now I would like to be able to influence the some data manipulation tasks in the RTOS application without changing the code of the RTOS application. So a concept like calling a dll.
My idea was to create a class with virtual methods in the RTOS application. The objects that are used should then be created on the Windows side with the same class prototype, but specific implementation of the virtual methods. The objects should then be moved to the shared memory, where they are used by the RTOS application.
Is something like this possible or am I completly on the wrong path?
View 4 Replies
View Related
Feb 16, 2015
Im using SDL2 but I'm encountering an unexpected error. I have implemented the same method to move as in my old Projects, but the Player appears to be stuck...
The Player is stuck for maybe half a second, and then everything works as it should, but every time I Change direction or i start moving the Player is stuck for a short Moment.
#ifndef _PLAYER_HPP_
#define _PLAYER_HPP_
#include <iostream>
#include <string>
#include "SDLGameObject.hpp"
class CPlayer : public CSDLGameObject
[code]....
View 9 Replies
View Related
Oct 21, 2014
I'm working on designing a game in C++ that is similar to the "find the ball under the cup" game. I have a Sonic the Hedgehog icon (weird I know, but it was the first thing that came to mind) that will be hidden underneath one of three rectangular blocks.
Here is how I envision this working:
On the main menu I have 3 buttons which represent 3 different difficulty levels
Easy- blocks move 3 times at a slow speed
Medium- blocks move 5 times at a slightly faster speed
Hard- blocks move 10 times at a fast speed
When the user clicks one of these buttons they will be taken to the game screen.
Sonic will be displayed for 3 seconds and the user will then see him be covered with one of the three blocks.
The three blocks will then move in a random pattern along the middle of the screen at the speed and number of times associated with the button that was pressed.
Once the blocks stop moving, the user is to click on the one they think Sonic is underneath.
If they choose correctly, they'll be taken to a "Winning Screen" that displays a congratulatory message and 2 buttons. Play Again- returns the user to the main menu and the game starts over with a new random pattern. Quit- the window closes.
If they choose incorrectly, they'll be taken to a "Losing Screen" that displays a "Try Again" message and 2 buttons that have the same function as the buttons on the winning screen.
I have never worked with any kind of graphics before other than in HTML and Javascript. I have managed to create the main menu, but how to do the actual game portion of the project. I've been trying to take it a step at a time, (for example, I first figured out how to set the background color for the console window, after I got that right I figured out how to add buttons) but the rest of this seems to depend on each other.
Here is what I have so far:
Main menu:
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
class MainMenu
[Code]....
So I've got the screens pretty much designed now (with the exception of the game screen itself) but how to tie everything together.
In case my description wasn't too clear, here is a game that I found on Google that is pretty much exactly what I'm looking for. [URL]
View 2 Replies
View Related
Apr 6, 2014
I need the number of moves to reset to zero every time because right now when when i enter the next number of disks the moves from before are added to the new set of moves. Here is my output
how many disk are you going to start with? 2
It will take 3 moves
how many disk are you going to start with? 2
It will take 6 moves
how many disk are you going to start with? 2
It will take 9 moves
how many disk are you going to start with? 2
It will take 12 moves
how many disk are you going to start with?
the number of moves for 2 disks should be 3 but as u can see every time i enter 2 disks it just adds to the last number of moves how can i fix this ?
//Purpose: Recursively solve the tower of hanoi problem, moving n disks from A to C.
#include<iostream>
#include<conio.h>
using namespace std;
double number;
void move(int,char,char,char);
//function prototype
[Code] ....
View 2 Replies
View Related
Apr 24, 2013
I am trying to pass an array of objects however i m finding some problems.
pieces.h
Code: class Cpiece{
public:
Cpiece* board[8][8];// array of objects
virtual char getcolor() =0;
virtual char setcolor(char colour)=0;
[Code] .....
View 10 Replies
View Related
Apr 17, 2014
I am writing a program for a poker game.. I created a class to get cards and create deck.. the problem I am having now is how to deal 5 cards to an array to ve evaluated later. I want to call the array player1[5]. I tried to use pointer but I get the following error
#include <stdlib.h>
#include <iostream>
#include <ctime>
#include <algorithm>
using namespace std;
const char* FaceString[13] = {"Ace", "2", "3", "4",
"5", "6", "7", "8",
"9", "10", "Jack", "Queen", "King"};
[code]....
View 4 Replies
View Related
Apr 16, 2014
I am trying to write a poker program. I created a class to create a deck of cards..and then shuffle the deck..Now I am trying to pass value from the deck to an array to deal a hand..so 5 cards to player1[] array.. I tried doing it directly such as.
for (int j = 0; j < 5; j++) {
getCard=deck[j].toString();
}
But I would get error such as [Error] no match for 'operator=' in 'player1[j] = deck[j].Card::toString()'
So then I tried using a pointer..
char *getCard;
getCard = new char;
for (int j = 0; j < 5; j++) {
getCard=deck[j].toString();
}
but I would get this error [Error] void value not ignored as it ought to be. So how can I pass a value from the object deck..to an array? or should I be doing it another way?..I tried to think of a way to do it via a function but really got hung up there..
here is full code
#include <stdlib.h>
#include <iostream>
#include <ctime>
#include <algorithm>
using namespace std;
const char* FaceString[13] = {"Ace", "2", "3", "4",
"5", "6", "7", "8",
"9", "10", "Jack", "Queen", "King"};
[Code] ....
View 11 Replies
View Related
Mar 21, 2013
I'm working on a personal project with a screen that looks like this:
+++++
+++++
++O++
+++++
+++++
And below that it asks where you want to move. I've done the majority of the work, I just have to figure out how to actually move the O. Here's my source code:
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
[Code]....
View 2 Replies
View Related
Jul 5, 2014
I know there is strtok() to do the tokenization;but all strtok() examples I have seen only output one token at a time, moving the pointer ahead. Can't the tokens be saved somewhere?
View 6 Replies
View Related
Nov 22, 2012
I have to write tic-tac-toe game in Visual 2010. My only problem is that I don't know how I can move the cursor with arrows in the console in order to fill in chosen positions in 3x3 table:
Code:
_ _ _
_ _ _
_ _ _
I guess that the needed functions are in here: [URL] ....
but I don't know from what to start with...
View 1 Replies
View Related
Jun 17, 2013
typedef tr1::unordered_map <string, pin *> pin_cmp;
pin_cmp _pin_cmp;
_Pins[_num_pins] = new pin (pin_id, _num_pins, s, n, d);
_pin_cmp[_Pins[_num_pins]->get_name ()] = _Pins[_num_pins]; //performance profiling
What actually the code doing?
_pin_cmp[_Pins[_num_pins]->get_name ()] = _Pins[_num_pins]; //performance profiling
I am not familiar with unordered_map which still can use with array[].I am confuse unordered_map just need key and value why will have array[]?
View 1 Replies
View Related