#### Archived

This topic is now archived and is closed to further replies.

# My newbieness revealed, I must ask a couple small things

This topic is 5921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, I know C++ up to the point that I knew Pascal and BASIC. I am NOT used to the Visual Studio environment for programming (I used QBasic not VBasic) I know this is taking up board space but i''m asking honestly, because i know you guys are the ones that can help first off, (A), i''m sorta understanding what classes are, but its kinda beyond me at this point with the Visual Studio layout... Could someone give me an example in a reply or in the form of a sample VC++ workplace, showing me how classes work? This is the real difference i''ve noticed between the other languages and this. second off, (B), I have been doing all those goofy little equations with CIN and COUT and all that JUNK that you guys stopped doing years ago. I''m sick of it. This is a weird question, but i''d like to have some proof in my own mind that i can do ANYTHING beyond this- what I really want to do is draw a pixel on the screen. a pixel on the freaking screen. ONE FREAKING PIXEL. Can someone tell me how to set up resolution size and whatever, along with a putpixel command? THANK YOU I gotta run -Pat Sodacider@home.com

##### Share on other sites
Smoke Weed!, It all makes sense then

##### Share on other sites
Ok, for you.... I was once at the same place. Quite possibly the best book for your stage is "Tricks of The Windows Game Programming Gurus" by Andre LaMothe. If your poor, broke, just beg your parents. Plead to them that it is for your future. It is a really good book, covering almost everything needed in 2D.

Then, a while after that. DONT JUMP TO THIS STAGE.. Or you''ll regret it. Once you''ve read a hella lot of that book, get the CDX Game Library. That book causes a lot of errors if you ask me, once you get later in it. BUT!!! It is VERY good in the beginning. And just ASK!! if you got a question about anything.

P.S. You can''t just ask to see something, or be able to do it... You gotta learn it, so you can do it yourself.

##### Share on other sites
The MSVC interface just shows you what you type. Write the class on your own, and it will put it in its class menu for easy browsing (a class browser helps a lot when you have a huge code base). Getting a pixel on the screen (in Windows) is a whole lot harder than you''re thinking it is. Maybe someone else will take the time to post the numerous ways of going about it...

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
quote:
Original post by Sodacider
... Could someone give me an example in a reply or in the form of a sample VC++ workplace, showing me how classes work?

You could look, you know...

quote:
second off, (B), I have been doing all those goofy little equations with CIN and COUT and all that JUNK that you guys stopped doing years ago.

Those weren''t equations.

quote:
what I really want to do is draw a pixel on the screen. a pixel on the freaking screen. ONE FREAKING PIXEL. Can someone tell me how to set up resolution size and whatever, along with a putpixel command?

Under Windows there''s a whole bunch of ways to do it. Probably the quickest for you is to use Allegro or SDL.

I wanna work for Microsoft!

##### Share on other sites
I sympathize since I started programing in quickbasic (the compiled version of qbasic). I had the benefit of starting to program graphics in C++ in DOS though, which despite its pecularities is more straightforward than dealing with windows.

To get out just one pixel in windows really is a Herculean effort. You have to first know your C/C++ programming, then you need to learn the windows API on top of that (and maybe Direct X on top of that later on). I suggest you get a firm handle on C/C++ first, then learn at least createwindow (to make a window) and message processing (for keyboard, mouse, and other OS alerts)in the Win API before moving on to Direct X.

Java is really much easier to learn and program for the begginner window and graphics wise, but no one ever seems to like my suggestion that they learn java first , and you already have VC, so I suggest starting
here: http://sunlightd.virtualave.net/Windows/

##### Share on other sites
Er, well, your pixel plotting question is so open ended it''s not even funny. It depends on what platform you''re using. If you''re in DOS, you could probably plot a single pixel with about a dozen lines or so. If you''re under Windows, that number is probably going to at least triple. If you''re on a *nix, things get alot more challenging because the OS isn''t very happy with you poking into video memory--whoops, a nerdy pun there

Classes... Well, think of classes as generalized descriptions of things. Like if you had a class called "ComputerMontior" it could contain a number of variables (called "members") that are pretty universal for monitors. You might have members called CRTSize, CaseColor, BrandName, Connector. The class itself is like a blueprint--in this case you have a "blank slate" with which you can describe many monitors.

If you later "create" a "monitor," you end up with an "object" of class type "ComputerMontior." For example, you might have ComputerMonitor E70 (Like the one on my desk...) which has the following member values:

CRTSize=17
CaseColor=WHITE
BrandName="Panasonic"
Connector=DB15

But you could just as well have (If you do have, gimme! ) a ComputerMonitor called GDMFW900, with these values:

CRTSize=24;
CaseColor=SILVER
BrandName="Sony"
Connector=DB15

You could pretty much come up with any number of monitor configurations, but they could all be generalized--or "abstracted" with the ComputerMonitor class. This is why a class is commonly referred to as an abstract data type, or ADT if you''re the abbreviating type.

Ok, that''s the basic stuff. If you want more of the story, read on!

Furthermore, you can add even more abstraction to the whole situation by "deriving" classes, which means you have one "base class" and a bunch of "derived classes" which inherit parts of the base. For example, you might have a class called "ComputerPart" that has a member called Connector and BrandName, and then the "ComputerMonitor" class might be derived from that, so it has BrandName and Connector members, but also adds the CRTSize and CaseColor properties. Later, you might derive ANOTHER class called LCDScreens which is derived from ComputerMontior.

Classes really become useful when you realize that while they can contain member variables, they can also carry member functions, which can act on the member variables as well as receive parameters just like any other function.

Member variables are commonly referred to as properties.
Member functions can also be called methods.

Finally, classes can have their members (both variables and functions) seperated by access, which means that you can specify whether they''re "public" and other functions/routines can use them, or if they''re "private" and only that class can get at it. An example for this would be if you had a function that contained a pointer to some region of memory. You don''t want any other functions sticking their nose into that memory, so you make it private, and then only objects of that class can use that member variable.

Although I''ve probably got your head spinning by now, there''s also something called "friends" which sort of bypasses the access rules and lets other functions outside the class touch it''s private bits. That didn''t come out right.

Now that I''ve dumped the whole class story on you, I hope you can sift through it and find what you need.

##### Share on other sites
// Possibly the easiest way to get some color on the screen
// the fastest way possible
// create a console project and cut and paste this code
// into it, compile and run =P

  #include #include #include using namespace std;int main(){ unsigned long NumColored=0; COORD coordScreen = { 0, 0 }; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); string str = " \n"; cout << str; FillConsoleOutputAttribute( hConsole, // handle to screen buffer BACKGROUND_GREEN, // color attribute to write str.size(), // number of character cells to write to coordScreen, // x- and y-coordinates of first cell &NumColored); return 0;}

// after playing around with this for a little while I
// would learn how to create a WIN32 application and learn
// stuff like SetPixel() etc
// after that I would move on to DirectX

// most of this stuff you can find in the VC6 Help
// and I would recommend getting a book like
// Isometric GameProgramming with DirectX and look at some
// tutorials on this site too ...Good Luck

[edit added [ source ] tags]

Edited by - Magmai Kai Holmlor on November 4, 2001 9:56:51 PM

Edited by - Magmai Kai Holmlor on November 4, 2001 9:57:24 PM

##### Share on other sites
ugh, the #includes
#include iostream
#include string
#include windows.h

with the lesser and greater signs around them

##### Share on other sites
ugh again,
the variable str had ten whitespaces in it or so.
just put anything u want in str basically.
everything was screwed up by the HTML.