C++ :: Representing Entities With MI

Dec 24, 2013

I'm trying to make a space shooter and I want to make the code very reusable. So far I've been making a bunch of objects with multiple inheritance like this:

entity: anything which can be drawn, has a position and an orientation
solid: any entity which can collide with something else
mobile: any entity which can move
spriteEntity : an entity drawn using a sprite
vertexEntity : an entity drawn out of vertexes

The entity class has the virtual method draw, which gets defined by either spriteEntity or vertexEntity. mobile and solid virtually inherit from the entity class.

Then I could create a projectile class which inherits from solid and mobile but adds methods to damage stuff it collides with, and multiple subclasses which inherit from both projectile and spriteEntity... But I'm not sure if it's a good idea to go this deep in multiple inheritance for game objects. I know MI has a bad reputation.

I know that some objects of the game will be sprites and some will be vertexes, and I also know there will be stuff which collides and doesn't move... Or should I make the mobile class a subtype of solid?

View 6 Replies


ADVERTISEMENT

C Sharp :: How To Bind WPF Datagrid Radio-button Column To Entities Class

May 7, 2012

In my WPF application I created a LINQ to SQL entities class. Then I created a partial class and there add code to my entity class. Below is the code of it:

namespace Mynamespace {
    partial class rts_index {
        #region Fields  
        /// <summary>
        /// Status:
        /// "Selected" - true, "Unselected" - false.
        /// </summary>
        private bool _is_selected;

[code]....

Then I executed LINQ to SQL. Works perfectly well. Then I bound WPF Datagrid radiobutton column to is_selected property of the partial class. Below is XAML code:

.
.
.
<Window.Resources>
<CollectionViewSource x:Key="rts_indexViewSource" d:DesignSource="{d:DesignInstance my:rts_index, CreateList=True}" />
</Window.Resources>

[code]....

And here I have the problem. When I'm changing the radiobutton status from Unchecked to Checked it doesn't change the value of is_selected property from false to true in the partial class. I don't know why.

View 1 Replies View Related

C++ :: Representing A Rectangle With Only 3 Variables Instead Of 4

Apr 6, 2013

how to use 3 variables to represent a rectangle in a grid instead of using 4. The traditional way is to use (x,y) (x2,y2). I propose using (x,l,h).In the traditional way as you probably know, (x,y) is the left op most corner, and (x2,y2) is the bottom right most corner. In the way I am proposing X is the left side, l is the length of the top side, and also the length of the bottom. 'h' is the height of the left and right. I think it's obvious how these three can define a rectangle same as the four.

View 2 Replies View Related

C/C++ :: Structure Representing Point In XY-plane

Mar 18, 2015

We are supposed to create a point structure that can be used to represent a point in the xy-plane. Then, write a menu-driven C++ program that uses variables of type point to perform a variety of tasks involving points in the xy plane, including slope, distance, midpoint, equation of a line passing through points, and colinearity. One of the functions we are to create is simply for reading in the user-input in the following form "(x,y)" with the user entering the parentheses and comma. We are to create two functions that translate back and forth between this format and what the assignment calls "one point variable."

I'm confused how I'm supposed to take the user entering, say "(1,4)" and reading that into an x and y, and then comparing it against another set of points. I'm guessing I read them in as a, b, c, d, but I'm not sure what this has to do with a structure.

View 1 Replies View Related

C++ :: Create A Class Representing Project Activities

Mar 24, 2013

Create a class representing project activities. In this class include all the required data members and member functions. Each activity should have a record of activity duration, calculated early start, early finish, late start, late finish, free float, and total float. Each activity may or may not maintain a list of its successors and predecessors. Provide your design in UML and implement it in C++ using an interface head file and an implementation source file. I do not understand classes or UML designs.

View 2 Replies View Related

C++ :: Read (three Digit) Integer Representing Value To Be Encrypted

Nov 3, 2013

I have been working on some C++ code that doesn't seem to be going right. I'm wanting it to read a (three-digit) integer representing the value to be encrypted, a (one-digit) integer representing the encryption key, encrypt the value and print the encrypted value. The encrypting method used is that each digit in the given number is replaced by ((the sum of that digit plus key) modulo 10) then the first and last “encrypted” digits are swapped.

For example, if the number entered was 216 and the key given was 7, after applying the encryption procedure described the first digit (2) would become 9, the middle digit (1) would become 8 and the last digit (6) would become 3. The first and last encrypted digits are then swapped. The program displays the encrypted number: that is 389 in this case.

#include <iostream>
using namespace std;
int main() {
int isolateDigits();
int replaceDigits();
int swapDigit1withDigit3();

[Code] ....

View 1 Replies View Related

C++ :: Array Of Hex Numbers Representing A Binary Number

Sep 24, 2013

So basically I have an array of hex numbers representing a binary number. Each binary number is 1/5th layer of the over all font.

For example... the letter A

........ B00000000 0x00
.****... B01111000 0x78
...*.*.. B00010100 0x14
...*..*. B00010010 0x12
...*.*.. B00010100 0x14
.****... B01111000 0x78
........ B00000000 0x00

As you can see each HEX number is a layer in the font which consists of in the above example 7 layers.

Now what I would like to do is create a C++ program, so I can visualize a HEX font array that I got off the internet.

#include <iostream>
using namespace std;
const char font[][5] = {
{0x00,0x00,0x00,0x00,0x00}, // 0x20 32
{0x00,0x00,0x6f,0x00,0x00}, // ! 0x21 33
{0x00,0x07,0x00,0x07,0x00}, // " 0x22 34
{0x14,0x7f,0x14,0x7f,0x14}, // # 0x23 35

[Code]...

Basically I am asking two things. How can I make this display the correct representing letter in the array when a user inputs his own text.

And secondly, how can I output the HEX numbers that is in the array as a binary number.

View 1 Replies View Related

C++ :: Random Numbers (Representing X And Y Co-ordinate) Grid Reference

Sep 18, 2013

How to code the following:

I have two random numbers which are generated and are related to each other (representing x and y co-ordinate). These random numbers are generated within a specified range: (-range, +range).

I want to categorize these values in a (2-dimensional) grid. The grid size is not definite and so can be varied by the user would be in the order of 400 x 400. (e.g., think CCD detector). For each random number pair (x, y) I want to store a hit (a plus one) in the corresponding grid reference.

In the order of 500,000 related random numbers (x and y) are to be generated and the position recorded according to grid reference. So code needs to be fast.

View 8 Replies View Related







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