473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Static Binding Problem:

I have kinda complex question. I am writing a game program and I am
trying to derrive things from my graphic library. For starters I want
to derrive the terrain from my graphics so that I can re-use my
graphics for other things like units. My graphic library works fine.
All I changed was graphic * trn to terrain trn[5]. So I am calling it
from a non-pointer array.

Here is some of what I got, if more is needed let me know:

static graphic * g1; <- this is a graphic that displays fine.
static terrain trn[5]; <- this object works but doesn't display
graphics.

g1 = new graphic(pgr); <-creating a graphic with a BYTE type

trn[0].SetAll(255, 255, 255, bits); creating terrain with color
and BYTE type
trn[1].SetAll(0 , 255, 0 , bits);

if(b->GetSpace(y,x)){
num = b->GetSpace(y,x);
SetTextColor(hdc,RGB(trn[num].red(), trn[num].grn(),
trn[num].blu()));
trn[num].display(hwnd,convert(y),convert(x)); <-This
worked as a graphic
but not derrived in terrain

g1->display(hwnd, convert(3),convert(5)); <-This displays find
which I use the same code as the base of the terrain object.

class terrain : public graphic{
float mvcost;
int defence;
int r, g, b;
public:
terrain(): r(0), g(0), b(0){}
terrain(int, int, int);
void SetColor(int rn, int bn, int gn){r = rn; b = bn; g = gn;}
void SetAll(int, int, int, BYTE c[]);
int red(){return r;}
int grn(){return g;}
int blu(){return b;}
float move(){return mvcost;}
};

Basically I don't understand why graphic is not working as base of
terrain.

Aug 13 '06 #1
2 2098
JoeC schrieb:
I have kinda complex question. I am writing a game program and I am
trying to derrive things from my graphic library. For starters I want
to derrive the terrain from my graphics so that I can re-use my
graphics for other things like units. My graphic library works fine.
All I changed was graphic * trn to terrain trn[5]. So I am calling it
from a non-pointer array.

Here is some of what I got, if more is needed let me know:
"My car is not working. What should I do?"

We need more. Read the FAQ:

http://www.parashift.com/c++-faq-lite/
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
static graphic * g1; <- this is a graphic that displays fine.
static terrain trn[5]; <- this object works but doesn't display
graphics.
[...]
trn[num].display(hwnd,convert(y),convert(x)); <-This
worked as a graphic
but not derrived in terrain

g1->display(hwnd, convert(3),convert(5)); <-This displays find
which I use the same code as the base of the terrain object.
How is it not working? It is green instead of red? Does it display
hexadecimal instead of base64? Did the cat scream when you started the
program? Explain the wrong behaviour and provide a compilable example, when
possible.
if(b->GetSpace(y,x)){
num = b->GetSpace(y,x);
What range is num in? When it is 0<=num<=4, you wasted an array slot. When
it is 1<=num<=5, you should substract one.

--
Thomas
Aug 13 '06 #2

Thomas J. Gritzan wrote:
JoeC schrieb:
I have kinda complex question. I am writing a game program and I am
trying to derrive things from my graphic library. For starters I want
to derrive the terrain from my graphics so that I can re-use my
graphics for other things like units. My graphic library works fine.
All I changed was graphic * trn to terrain trn[5]. So I am calling it
from a non-pointer array.

Here is some of what I got, if more is needed let me know:

"My car is not working. What should I do?"

We need more. Read the FAQ:

http://www.parashift.com/c++-faq-lite/
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
static graphic * g1; <- this is a graphic that displays fine.
static terrain trn[5]; <- this object works but doesn't display
graphics.
[...]
trn[num].display(hwnd,convert(y),convert(x)); <-This
worked as a graphic
but not derrived in terrain

g1->display(hwnd, convert(3),convert(5)); <-This displays find
which I use the same code as the base of the terrain object.

How is it not working? It is green instead of red? Does it display
hexadecimal instead of base64? Did the cat scream when you started the
program? Explain the wrong behaviour and provide a compilable example, when
possible.
if(b->GetSpace(y,x)){
num = b->GetSpace(y,x);

What range is num in? When it is 0<=num<=4, you wasted an array slot. When
it is 1<=num<=5, you should substract one.

--
Thomas
Thanks, I found the problem: I failed to clear the vector which holds
the data I was appending the new data to the end of the default data.
Now I have to place the units on the map and that may not be too hard.

Aug 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Michael Muller | last post by:
Is there currently any plan to introduce static typing in any future version of Python? (I'm not entirely sure that "static typing" is the right term: what I'm talking about is the declaration of...
2
by: K | last post by:
Hi all; I don't think this is a VC compiler question, so I am asking this here. I did hunt around the web and Stroustrup before posting, but found no references to this problem. I have a base...
5
by: Tony Johansson | last post by:
Hello experts! Why is not possible to have virtual static members Many thnakn //Tony
1
by: Thomas Fritzen | last post by:
I have a problem with static functions and inheritance as demonstrated by the below samples using System; namespace ConsoleApplication1 { class x { public static void Log() {...
4
by: hack_tick | last post by:
Hi Guys! Is function overloading a kind of static polymorphism?
14
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared...
2
by: 09876 | last post by:
Hi: all I understand the difference between dynamic binding and static binding. But I just wonder what is the point to make the distinction between the dynamic binding and static binding. For...
0
by: Mahmoud Al-Qudsi | last post by:
Hi all, What is the recommended way of binding controls to a *static* datasource? In my project, I have to use the same ADO.net data source/ bindingsource in mulitple forms and across...
37
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
12
bilibytes
by: bilibytes | last post by:
hi, i need some help here. how can i access a static property of a subclass. i have an abstract class which will be extended... each extending class will have a static property that will...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.