C++ :: Making Simple Game In SMFL - Player Class Does Not Have Type
Jul 20, 2013
I'm trying to make a very simple game in SFML, and i have a problem. Whenever i try to create sf::Sprite for the class where all properties of Player (his sprite, health, speed, etc.) It gives me error.
#include <sfml.h>
#include <list>
class Playerclass{
public:
int xspeed, yspeed;
float health;
sf::Sprite entsprite();
[Code] ....
The error is with player.entsprite.setTexture(texture) : "'player.Playerclass::entsprite' does not have class type".
View 2 Replies
ADVERTISEMENT
Feb 26, 2014
I have a sword(25 damage), spear(20 damage), arrow(15 damage), dagger(10 damage) and knife(5 damage). I want to make a class for them so that I can equip one of them in battle and use them to inflict damage.
View 1 Replies
View Related
Mar 24, 2015
I am making a simple arkanoid game. When the ball hits the block, i want the block to disappear. How would i go around this? i am working in visual studio. I got the collision and everything working.. Here is my code;
int main(int argc, char** argv){
//initialisation
SDL_Init(SDL_INIT_EVERYTHING);
SDL_WM_SetCaption("Graphics Window",NULL); //set name of project
//variable declaration
SDL_Surface*screen;
boolrunning;
intgameState;
float startTime;
[Code] ....
View 1 Replies
View Related
Apr 10, 2014
I'm having some problems with implementing an AI. It should be just a simple AI that follows player. Here is the code that I got so far:
(float)DirectionX = Circle->GetX() - AI->GetX();
(float)DirectionY = Circle->GetY() - AI->GetY();
(float)Hyp = sqrt(DirectionX * DirectionX + DirectionY * DirectionY);
DirectionX /= Hyp;
DirectionY /= Hyp;
x += DirectionX * 3;
y += DirectionY * 3;
This is what I got so far. It creates a vector in a direction I want to move, then just normalizes the vector. Simple as that. But I'm having 2 problems..
AI moves towards player only when Im at like the end of screen and the AI is on the other side, I must keep a certain distance for it to be able to move towards me. Basically, its not constantly moving towards the player. I also tried it with trig, using atan2 for angle and sin / cos for speed. Also didn't work, same result.
The other problem is when I want to add i.e 5 more AIs. For each new AI it creates, it makes a new update.. So, to kinda clear it up. If I'm in middle of the screen and an AI is spawned above me, it will move towards me. But when after that one, 2nd AI spawns beneath me, both 1st and 2nd AI move up. Basically, previous AIs take the update from last one that is created. For updating I'm using lists, objects and iters.
View 3 Replies
View Related
Oct 21, 2013
I am writing a game that is 2 to 4 players. i am wondering how to ask how many players, and make the score stay with each player. it is a rip off of zombie dice, this is what i have so far the playerScore array is to hold the score for each player and the turn array is hold hold the values that they rolled that turn, i also dont know how to clear out the turn array when it goes to the next player.
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main() {
int playerScore[4];
[Code] ....
View 3 Replies
View Related
Feb 26, 2015
I'm having some problems figuring out 3 and 4 player games in an Uno game I'm working on. I'm not sure what specifically the problem is, however. I've tried everything I can think of; I'm at a loss for what to do next. Two player games work perfectly, which makes the nonfunctional 3 and 4 player games seem odd to me. Here is the code:
public void MoveOpponents() {
if (nextPlayer == 0) {
if (Main.dir == Direction.Clockwise) nextPlayer = 1;
else nextPlayer = numPlayers - 1;
[Code] .....
The code for the human player is in Update(), but I won't show that because it's actually quite similar to the above code.
Right now what it's doing is jumping all over the place, making opponent 2 play before opponent 1, then I play, then opponent 1 plays. Then I play again. It's really messed up.
View 6 Replies
View Related
Apr 19, 2013
Here is the code I have written so far. My problem is that when the second user enters its position the last user's position is wiped of the board. I want to know how I can hold that position and keep doing so until the game is finished. I thought that calling the previous function would do that (and you can see where I have put that into a comment) but it doesn't.
Code:
#include <iostream> //includes header file
using namespace std;
//function prototypes
void printLeftUpper(int i, int j);
void printMiddleUpper(int i, int j);
[Code] ....
View 1 Replies
View Related
Mar 19, 2013
I have started making a text adventure game.
if (Choice == 2) {
cout << "" << endl << "You follow the light to the end of the hallway, you find your self in a room" << endl
<< "with natural light coming from a hole in the ceiling." << endl << "" << endl << "You hear the door you just came through, slam behind you!" << endl << "" << endl
<< "There are three possible directions." << endl << "" << endl << "Do you:" << endl << "" << endl << "1) Go forward" << endl << "" << endl << "2) Go left" << endl
[Code] .....
Ignore the if (Choice == 2) at the beginning, that's linked to some previous code.
I want to make the player go back to the first bit of text but i'm not sure how to do this if they keep choosing to go back and forth from one location.
I first thought of doing it by just putting the text back in after they have chosen the option, but I can't do this infinite times.
View 5 Replies
View Related
Nov 1, 2014
I am making a game which is a two player strategic battle turn based game..... The game will require each player to choose a attack. What would be the best key configuration for set of four attack. Like
player 1: 1,2,3,4;
player 2: 7,8,9,0;
where 1&7 are for kick 2&8 are for punch etc.....
or
player 1: q,w,e,r;
player 2: u,i,o,p;
View 2 Replies
View Related
Sep 20, 2014
I wish to create a simple animation, similar to the pong game but completely automatic (i.e. both sides play against eachother sort of like in a screensaver of sorts).
I am clueless on to even start tackling this, what tools to use and how to use them, to make them do what I want. I have had some experience with C++ scripting while modding Fallout 3, but I'm not sure how similar the scripting system available in the SDK for that game, is to the real thing.
Like I was saying I want to create a simple animation where two AI blocks try to prevent a ball from reaching the wall behind them.
View 3 Replies
View Related
Feb 27, 2015
Here's my game, what do I need to learn to make a basic GUI? (Easiest way possible for now).
--NOTE, the code was a bit too long for me to post. I can add it if it is necessary. Basically all I want are 4 buttons on the main screen, one that says "Arena," "Store," "Stats," and "Exit."
There will of course be sub menus to each option, but we will get to that later.
View 1 Replies
View Related
Jun 6, 2014
I am making an open world RPG game. I have already done the graphics rendering (with directx 11 on windows 8). I am a bit confused of how to load all of this data in, and I looked into how the game Skyrim did it. I didn't find much information about it at all, apart from it uses cells for each bit of the game, and if you character were to kick a pumpkin (for example) it would record the new location in the player's save file. The same goes for spells, perks, quests, etc.
My problem is, I'm not sure how to implement something similar in code!
View 4 Replies
View Related
Sep 14, 2013
i am making a space game using sfml 2.0. i want it to move depending on its rotation. so if it is rotated 20 degrees it move in the direction it is facing. how do you do it?
View 17 Replies
View Related
Jan 23, 2013
Making/Building 3D Game Engines, Do I need to know anything related to ART or graphics in order to make them ? I mean, I do know that having a know how about vectors is VERY important, But I am no good at art, I suck. I have thought of getting a separate guy to do the art, as I'm more interested in writing code and then implementing it making use of the art that has been made, I'm just worried if I need to or not need to know anything about sketching or art in order to write a 3D Game engine ?
View 8 Replies
View Related
Oct 2, 2013
when it comes to programming. I was trying to make a simple letter guessing game where the user has 6 chances to guess the letter V. The command prompt works fine until the user enters 'y' to play. It repeats my HIGH & LOW statements twice before letting me guess again. It's all a mess.
View 2 Replies
View Related
Jan 31, 2013
I've been in the process of making a simple ascii game and worked out to make random terrain that wasn't all that bad (but has some flaws and is not very efficient). I came across midpoint displacement and the diamond square algorithms and was blown away by the results that come from using them. So I decided to try implementing one into my game but I'm having a really hard time coding it out. I have read a whole bunch on them but haven't really found any good tutorials that breaks it down into steps with sample code. I just need it stored in an array I can handle graphics and output.
ex: 5x5 array with all starting corners being 9 in height
98679
87658
76557
88789
98889
^^Something simple like that.
View 1 Replies
View Related
Oct 7, 2014
I am trying to draw a grid for checkers. I could draw a square at the starting point from origin with the code below(attached the pic below how it looks) however I am not being able to draw a grid when the program runs.
#include "ccc_win.h"
// GameDemo.cpp
// Shows how to place a piece accurately on a grid after a mouse click.
#include "ccc_win.h" // for graphics classes and functions
using namespace std;
int ccc_win_main(void) // main function for graphics program
[Code] ....
View 3 Replies
View Related
Oct 24, 2013
I am required to create a simple candy crush game.
I am this stage where I am required to print the 'box' for navigation purpose at the center of the board once the program initializes.
Here is the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//FUNCTION: Draw the Board
[Code].....
I understand that the sequence could be to clear the screen and print the whole board with the indicated marker.
*Yes I am required to move the box in later part of the program but for now, I just need to get the box to show up at coordinate
Code: board[5][5]
I am stuck ...
View 11 Replies
View Related
Sep 26, 2013
I have to write a program that simulates a handheld gaming system. a system can have power toggled so its either on or off. when the system is on, its volume level can be raised or lowerd. a system has minimum volume level of zero and a maximum volume level of 10. a system stores games.
// simple game menu
//simulates a handheld gaming system
using namespace std;
class Game {
public:
Game(int GameNumber = 3, int volume = 10);
[Code] .....
View 1 Replies
View Related
Jul 3, 2013
looking for a simple LED type control for Visual Studio 2008. I just need a control that I can add to the toolbox where I can pass a parameter to define the colour. This is an MFC based application. how to add a new control to the toolbox. I have been programming in 'C' for many years but find some of the IDE's confusing as to how to do things (as above)
View 4 Replies
View Related
Sep 24, 2014
I have a templated container that defines a forward iterator.
Calling std::distance on these iterators will generate code that will count the number of iterations it takes to get from the first parameter to the second, by repetitively incrementing.
Internally, the iterators can easily find the distance by a simple subtraction.
What I want to do is overload std::distance for these iterators so that it will take advantage of the simple calculation rather than repetitive increments.
The simple solution of course would be to make the iterators random access, but this would require that they support functionality that is not 'logical' for the container. Access to the container only makes logical sense when iterating one item at a time in the forward direction.
Code:
#include <iterator>
template <typename T>
class Container {
public:
class iterator : public std::iterator<std::forward_iterator_tag, T> {
[Code] .....
View 2 Replies
View Related
Feb 18, 2015
I am having some serious issues with class inheritance. I am trying to make a MoneyBag class inherit from a class called bag. This will not work. I get an error complaining: error: expected class-name before '{' token. And yes I have googleing it and tried several of the various solutions offered with no avail.
The MoneyBag is pretty simple right now as I wanted to get it connected to bag before I tried to do anything with it.
//MoneyBag.h//
#ifndef MONEYBAG_H
#define MONEYBAG_H
#include <bag.h>
class MoneyBag : public bag{ ////<<------ Error appears on this line.
[Code] ....
So based on everything I have seen on line the statement:
class MoneyBag : public bag{ is legal.
As it is done this way on this very site's tutorial:
class Rectangle: public Shape, public PaintCost{
View 2 Replies
View Related
Apr 19, 2014
I'm trying to make an templated class of List and trying to make a list of Students(another class) which I made. Its not working.
Code seems to work fine for pre-defined data types but it crashes when it comes to students. I also want to run sort function on list of students.
View 1 Replies
View Related
Apr 3, 2014
How can i write a function that will read an "unsigned integer" into a variable of type "unsigned short int"? i can not use cin >> inside the function.. so i am looking for atleast a hint!
View 16 Replies
View Related
Mar 25, 2013
I'm trying to make a class constructor within a namespace and I keep getting errors like: "'<variable>' is a nonstatic data member of class '<class>'" for when I try to setup parameters, and "Incomplete type is not allow" whenever I try to write out my function definition. Here's what I'm doing:
namespace test {
class blah;
} class blah {
typedef int var[5];
[Code] .....
Also I'm unsure why there is a parameter of 'const blah &' when I mouse over blah(); (using Visual Studio 2010) within the class definition. It tells me 'blah::blah(const blah &)' and I am unsure where the parameter comes from. How can I resolve these issues?
View 4 Replies
View Related
Oct 6, 2013
I am making a simple program that is suppose to make a list of champions and their items from the game League of Legends. I am stuck on making a vector of the class so each slot within the vector would hold each champion and its data. This is what I got:
Champion_Info.h
#ifndef CHAMPION_INFO_H_INCLUDED
#define CHAMPION_INFO_H_INCLUDED
#include <vector>
#include <string>
using namespace std;
class Champ_Info
[Code] ....
View 3 Replies
View Related