C++ :: Video Game Programming - How To Display Graphics And Set Properties
Jun 10, 2013
How would you create a video game in c++? I'm not sure really how to display the graphics and set properties and do all that stuff. I don't have money to buy a book about so how do you?
Lets say that I try and make a BASIC game with c++, how do I make the animations/graphics for the game (i.e the characters ) Do I need a specific complier/ide (I am using visual studio)
I am working on a video game that is based on a tutorial I found online and I ran into an issue associated with accessing an object's method inside another class object's function without making the object global which seems bad.
Here is basically how the tutorial set things up in the game: The game has a base class called GameObject then there are other child classes that inherit from this class. The GameObject class has all the basic information an object would have that needs rendered on the screen (x/y position, size of bitmap, bitmap, whether or not it is collidable, etc).
One of the child classes SpaceShip, which is the player so it has attributes and methods associated with managing # of lives and points scored.
There are other child classes of GameObjects in the game that need to take life and add points from the SpaceShip object if they collide with the spaceship or other objects.
In the collision handling routine I basically call a function "void Collided(int objectID)" when a game object collides with another. Within the Collided() routine, there is logic that executes code or other functions based on the objectID it collided with. Some of the collisions require taking life from the spaceship or adding points. The way this was accomplished in the tutorial was with function pointers (see Bullet class constructor and collided method for example). Is this really the best way to handle this sort of thing? It seems like there has to be a simpler way than to keep referencing function pointers in any new class I want to add to the game. I realized this when I went to add a method for the spaceship to fire bullets rather than inside my game class.
#include <iostream> #include <stdlib.h> #include <time.h> using namespace std;
/* function main begins program execution */ int main() {
[Code] .....
I have gotten the conditions to execute properly but will end the program after doing a case instead of asking to play again and loop. Also how would i output the number of wins and losses?
I was tasked with creating a program that asks for the scores of three gamers then takes these scores and outputs the highest. I THINK I have the other parts down but I don't know how to get the program to compare the scores and output the highest without having to write a long list of commands comparing playerone to playertwo, then player one to playerthree, then player two to playerone, etc.
#include <iostream> using namespace std; int main () { int playerOne, playerTwo, playerThree; cout << "Please enter score for Player One: "; cin >> playerOne;
my a book or website where I can make a transition from console programming to GUI programming. I'm totally confused about this. I know how to program in console and can make a whole program based on console. I also know the OPP programming, but it's clear that nobody uses console programming anymore.
I have been writing a fairly simple turn based rpg game in c++ and at the moment it has a 2d integer array for the map, which I can display using periods for the blank areas and letters for the various people in the game, and I am trying to figure out how to upgrade to a tile based display.
Is it possible to access file properties from c++ program? For example, user could drag file to program and then it displays a detailed information about file like date modified, size, type and etc..
I have startes making a game where there is 3 ships that cross the screen verticaly, and the point is to shoot them down. So far I have actually managed to do this. I have also managed to add gamescore to the ships. But here is my problem, I cant find a way to combine the score from all three ships in to one score. I have all three ships in different classes, is that wrong? When I try to combine the scores, ship score1 cant see the other scores.
Do I need to somehow have all the ships in one class. Or are there a way to read the scores from three classes, and adding them up in to one in a new class?
One of the errors I get is "the name 'score1' does not exist in the current context.
I've been attempting to design a multiform WFA in Visual Studio 2010, but I'm so rusty with the language it's hard to remember how to do a lot of things, especially when it comes to visual programming, which my class only partially covered. I've never made a multiform application before, and my problem essentially boils down to how to pass data between forms.
My application is a simple item list and order form, sort of mimicking what you might see on a site like Amazon or eBay. My first form contains a drop down list and 'checkout' button. The dropdown list has been populated with an object collection, each object holding the product's name and price.
public partial class Form1 : Form { //Item class for dropdown menu public class Item { public string Name; public decimal Price; public string itemName
[Code] ....
When the 'checkout' button on form 1 is clicked, I want the Price and Name properties of the selected droplist item to appear in a pair of text boxes on form 2 for the purpose of lowering the user's cognitive load (if they can see what they've selected, it's one less thing to remember).
I've seen plenty of tutorials on how to send a textbox Text property between forms, but none for how to do this. As I said, I'm rusty with the language, and I'm pretty sure there's a better way to set up my combobox items, but I can't remember how to set it up.
public class MyClass { public int age { get; set; } } static void Main(string[] args) { MyClass testing = new MyClass(); testing.age = 44; Console.WriteLine(testing.age); }
output: 44
Code using regular variable declaration:
public class MyClass { public int age; } static void Main(string[] args) { MyClass testing = new MyClass(); testing.age = 44; Console.WriteLine(testing.age); }
output: 44
Why use the auto-implemented property when you can just as equally use the second code block to achieve the same thing?
I had written a "DLL" in VB.NET a year or two ago to read and set MP3 tags. I want to write this exact same library in C++ so I can convert it in my droid project, and to get a hands on introduction to C++. So far this attempt has been a total mind melt!
I am finally wrapping my head around .cpp and .h files so there is light at the end of this tunnel. Here is my problem now:
I wrote the VB project with properties for each tag in the MP3 file, then I could get and set them - easy stuff.
When I try this in C++ I get compile error: a property can only appear within the definition of a managed type. I can usually stumble through Google searches and figure out this type of stuff on my own, but this one is stumping me -- I think I am missing some fundamental stuff here.
My code:
// MP3Tags.h #pragma once; #include <string> using namespace std; using namespace System::IO;
I have been trying to make a custom control(list box with more features). I know how to setup custom properties, but how do I make it so that the property can be edited in a separate window ?
I think I figured out how to show the form itself, and I don't know how to make the [...] button like :
There's not much Custom Control tutorials out there, and that's really the problem here.
Well I know how to pass values between forms using get and set properties. But the problem with it is everytime I want to pass values from form2 to form1 it doesn't appear. To make it appear I have to type form1.Show(); which open form1 a second time and then show the value. Is there any way I could make it appear without using form1.Show();?
Kinda like in properties, where you choose the height and width of the window, but in actual code. So everybody who open my program see the same window.
I'm trying to get my head around threading and gui applications for fun, and I've ran into a problem I'm not too sure how to google it correctly or I don't understand the answers given. Basically I'm trying to access GUI item properties (add to a listview). I've been on stackoverflow alot, and I've noticed that accessing these properties is quite difficult. At least, I'm not really understanding how it is supposed to be done.
The following line gives me a null value.
frm.lstChat.Items.Add(newList);
From what I understand I need to access my form object instead of creating a new object window... but I'm not sure how to reference the initial form application.
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using System.Net.Sockets; using System.IO; using System.Threading; namespace ModBot {
How can I write my own container which has properties of both vector and list.
E.g. I can access elements directly using [] operator like vector and behave like list in terms of memory (means we don't have to shift elements if we want to insert in between like list)....