C/C++ :: Randomly Moving Characters

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


ADVERTISEMENT

C# :: Making Moving Button Or Moving Picture Box Clickable?

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

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++ :: Moving From One Coordinate To Another

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

C++ :: Moving In A Circle

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

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 View Related

C++ :: Moving Character Up / Down And Left / Right

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

C++ :: Moving The Head Of Array

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

C++ :: Moving Elements In An Array?

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

C++ :: Saving Moving Objects?

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

C++ :: Moving A Button And Image With Each Other?

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

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++ :: Moving Objects To Shared Memory

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

C++ ::  SDL2 / Player Not Moving Constantly

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

C++ :: Moving Elements In Array And Displaying

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

C/C++ :: Creating Moving Objects For 2D Game

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

C/C++ :: Moving N Disks - How To Get Number To Reset To Zero

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

C++ ::  Making A Moving Item Controlled By Using WASD

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

C++ :: String Tokenization - Moving Pointer Ahead

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

Visual C++ :: Moving Cursor With Arrows In Console?

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

C :: Max / Min Value In Randomly Produced Array

May 10, 2014

I am very much a beginner at C and a large amount of it still tends to go over my head, I've created a 2d array which its size is generated from user input and filled with random integers. Next I need to locate the maximum and minimum figures in the integer and as dull..This is the code I have so far

Code:

#include <stdio.h>#include <stdlib.h>
int main ()
{
int firstDimension, secondDimension, firstDimensionIndex, secondDimensionIndex,index;
int **table;
}

[code]....

View 2 Replies View Related

C++ :: How To Iterate Through A For Loop Randomly

Apr 5, 2013

So I have a vector that I want to iterate through randomly, and by random I mean that each element is only accessed once but I don't want to shuffle the vector because the vector elements are large. So I want this functionality:

std::vector<SomeLargeObjectWithoutACopyConstructor> myvec;
// ...fill myvec
std::random_shuffle(myvec.begin(),myvec.end());
for (auto& value : myvec)
{
// do stuff
}

Only I don't want to do this because the object type has no copy constructor and is large, so I don't want to shuffle the vector, just the iteration path. Is there a simple and efficient way of iterating randomly through a vector while ensuring that each object is only accessed once?

View 3 Replies View Related

C++ :: Loop Randomly Until Get All Seven Numbers

Nov 13, 2013

Is it possible to loop randomly. For example

for ( int i = 0; i<= 6 ; i++ )

I don't want i to acsend from 0 to 6 but i want it to get all numbers randomly. For example

first time r = 5 second time r = 2 and so on

until it gets all the seven numbers

View 4 Replies View Related

C++ :: Getting Sum Of Two Randomly Generated Numbers

Feb 15, 2015

I can't get the sum of two randomly generated numbers - I don't believe the program is adding wrong what I think might be happening is upon hitting enter its adding two new randomly generated numbers -

Code:
// Program functions as a math tutor
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int main() {
// Constants
const int Min_Value = 1;

[Code] .....

View 3 Replies View Related

C++ :: Dispatch Message Taking Frames Away While Moving Window

Oct 29, 2014

lets start with the code:

while(run)
{
if (PeekMessage(&msg, win->win_handle,0,0,PM_REMOVE))
{

[Code]......

I have created a basic window and i discovered that while resizing or moving my windows, the myframe() don't get any calls at all.

Is there anyway possible that myframe gets at least someof the calls while those things are happening

View 1 Replies View Related







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