Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / OOP w/ DarkGDK

Author
Message
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 11th Mar 2008 21:06
Nope. Actually, I had a little problem with that earlier, where it was opaque on the top, which is why I had to flip it upside down with 'dbXRotateObject( water->id, 180.0f )'. I'll see if I can figure out what's causing it.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Mar 2008 04:37
I think its a quirk - where it depends on the order in which they are loaded, not the images - the object meshes created. Like in the apache in the DBPRo version of Iron Infantry... I have alpha rotors (for heli rotor blur) if I loaded the top blade then the tail bladd,, then from one angle - the tail blade might always be dominant and see through, where from other side non -issue looks perfect. Alternate what loaded first, and it switches.

Molex
16
Years of Service
User Offline
Joined: 11th Mar 2008
Location:
Posted: 12th Mar 2008 05:40
I'd like to try it but I dont have darkphysics yet... Get alot of messages related to that dbphy while compiling. I might get that soon but stll trying to figure out darkgdk.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 12th Mar 2008 12:40 Edited at: 12th Mar 2008 12:40
Quote: "I think its a quirk - where it depends on the order in which they are loaded, not the images - the object meshes created. Like in the apache in the DBPRo version of Iron Infantry... I have alpha rotors (for heli rotor blur) if I loaded the top blade then the tail bladd,, then from one angle - the tail blade might always be dominant and see through, where from other side non -issue looks perfect. Alternate what loaded first, and it switches."


Ya, it's probably something like that. But hey, at least it looks ok from the top.

Quote: "I'd like to try it but I dont have darkphysics yet... Get alot of messages related to that dbphy while compiling. I might get that soon but stll trying to figure out darkgdk. "


Ya, unfortunately you need DarkPhysics right now to even compile it. I'll try and find a way around that, though, so if you don't have DarkPhysics you can simply set some flag or something.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Mar 2008 13:05
I think ALL of us "Wrapper Writers" should at least consider making the code in such a way that a simple compiler define can toggle the EXTRAS that aren't required.


#define USE_DARKPHYSICS
#define USE_SPARKY
#define USE_DARKAI


Where a simple:


//#define USE_DARKPHYSICS
//#define USE_SPARKY
//#define USE_DARKAI


Would make it "Go Away" for guys like Molex

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 12th Mar 2008 21:33
Ya, but how would you make it exclude any DP code??
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Mar 2008 00:10
Easy in theory - a pain to organize and do correctly -

1: I'm going to make a section in my most global include file (jgc_common.h) that has configuration stuff in it.

2: Use this configuration area to dictate tons of stuff all over the library, such as DEFAULT screen resolution, default autocam on or off, default timer length to scan mouse, and the one for joystick, oh... and the keyboard... And of course: USE Sparkys? Use DarkPhysics? Use DarkAI? etc.

3: For Each Cionfiguration - things like default values you use a compiler directive... ... Um Did I give it away?


4: The I use those Compiler directives to Direct the Compile LOL... It works like this kinda:



And you have junk like that ALL over your source code.

To Use Dark Physics in this case... my jgc_common.h file would have an entry like:


and to not use it I would just comment it out.


AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 13th Mar 2008 01:13
Okay, sounds good! I'll try it now.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 13th Mar 2008 01:28
It worked! I've updated my first post with a newer version that should work even if you don't have DP. If someone w/out DarkPhysics could try it out, that'd be great.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Mar 2008 05:07
Wow... That was a fast turn around! I Love hearing when things WORK!

Molex
16
Years of Service
User Offline
Joined: 11th Mar 2008
Location:
Posted: 13th Mar 2008 07:48
Thanks for the fast modification of your files, but I can't download it from the first post. I click on the download button, then save then it goes away. I can't find file anywhere on my computer. I'll try again later.
Molex
16
Years of Service
User Offline
Joined: 11th Mar 2008
Location:
Posted: 13th Mar 2008 07:57
Thanks for the fast work on making it work with out having dark physics. A bit tired now but I'll try it later and let you know.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 13th Mar 2008 12:40 Edited at: 13th Mar 2008 21:52
Quote: "Wow... That was a fast turn around! I Love hearing when things WORK! "


Lol, who doesn't?

I think I'm gonna start working on a GUI now. Nothing to complex, just some buttons, checkboxes, textboxes, etc.


::Edit::

Sorry, Molex, didn't see your post at first due to the approval system.

As for your problem, try opening it, not saving it, then copying the files to your HD. That should work.

Also, I've got buttons working with the GUI. To use them, you first have to create a GUI device.



Then, to create a button use:



There's not much functionality right now, but it's growing.

And you can download the update in my first post.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 13th Mar 2008 21:57
Sorry for the double post, but in case anyone was wondering I'm gonna become some documentation over the weekend, as well as create some examples to give out as well.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 13th Mar 2008 22:22
Andrew, think about how you would make an editor for such a gui toolset - make a form, drop controls on it, select them, size them, change properties... like read only, select images from harddrive, and then save this info so you can recall it in game!

Just think about it.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 14th Mar 2008 00:56
Nice idea! Once I've got more done I'll consider it.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 14th Mar 2008 01:31
I'm going to need to do this too... if you beat me too it.. COOLER!

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 14th Mar 2008 01:50
Haha, I don't think I'll be able to do that, I've still got a lot of things to do before I finish my GUI.
Molex
16
Years of Service
User Offline
Joined: 11th Mar 2008
Location:
Posted: 15th Mar 2008 03:56
Well I got it to compile but I am unsure how to use this. Seems like it will be easier to use than the normal dark gdk but I was wondering if there are any examples? One thing I don't get even to start is vecter2d, what is param? Normally I would give the x and y as sperate floats to create the vector.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 15th Mar 2008 06:28 Edited at: 15th Mar 2008 06:28
Okay, I've updated it once more. I split the source into several files to make it easier to view. I've also added a little to the GUI. Also, the download comes with an example of a spinning cube so you can get the basics down. I'll work on more examples and some help files tomorrow.

You can find the download on my first post.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 16th Mar 2008 00:25
Quote: "Well I got it to compile but I am unsure how to use this. Seems like it will be easier to use than the normal dark gdk but I was wondering if there are any examples? One thing I don't get even to start is vecter2d, what is param? Normally I would give the x and y as sperate floats to create the vector. "


I'm sorry, I didn't see your post until now. As for examples, I'm working on some right now. The newest update includes 2 - basics and input.

About the vectors, rather, than what DGDK does - specify two/three different floats - I use vectors instead. Basically, here's how it would work with separate floats:



Here's how I do it with vectors:



At first this might seem more complex, but really it's much more flexible, as you can add/subtract/multiply/divide them, compare them, etc. I'll post some examples using them later.

Regarding the latest update, I've added animated sprites. I should have an example on them soon.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Mar 2008 03:58
Good Job Andrew.

I spent ALL DAY coding ONE MENU! Still not 100% Done! Jeesh. Keyboard, Mouse Wheel, Mouse Click, Turn Menu On, Off, animate, Swap Images... More work than I anticipated... FOR ONE MENU!

(Though it is kinda fancy)

I still haven't made the defaults and the "Physics/Sparky" compiler directive stuff yet to my OOP lib.

Molex
16
Years of Service
User Offline
Joined: 11th Mar 2008
Location:
Posted: 16th Mar 2008 04:06
Thats alright on seeing post...I seem to be on parole till I prove I'm a good boy I guess ;/

Thanks on the info gives me a step in the right direction. I wasn't using them with sprites yet was just wondering how to use them. One thing I tried to do was work on that star field tutorial but so far cant get dots to draw sigh...

But do the vectors have to be used just like that?

My intention is to make a rts spaceship game simular to homeworld and I would want to store its variables in a spaceship class like current position and desination and such. Sprites don't seem to have a destination field. I haven't quiet desided if I want to go 3d or 2d yet.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 16th Mar 2008 05:04 Edited at: 16th Mar 2008 05:09
Ya, I imagine your menu is more complex than the one I'm using for Pong:



But I'm proud of it! The buttons actually work; if I click 'How to Play', the How 2 Play window disappears. And I can drag the How 2 Play window around by clicking & and moving my mouse, like with a window.

My animated sprites are working great now! The pong game you see above is a little demo game I'm working on to go distribute w/ source along with my wrapper.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 16th Mar 2008 05:31 Edited at: 16th Mar 2008 05:31
Well - Pong is a project in it of itself. And your project probably doesn't need more than you have - BTW - What you have looks nice.

I'll show you mine - but remember - this has taken literally days when you consider the bitmap font to image code, the model creation, the code to make it move, scale, and the various ways of useing it for the user (The biggest pain of all) LOL



Attachments

Login to view attachments
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 16th Mar 2008 06:00
Suh-weeet! I like it!
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 19th Mar 2008 02:29
Well Andrew... I have to report - that the OOP programming is REALLY paying off... I mean, I have tried to be consistant and stuff... and now when I'm doing my tests or whatever . I'm always just "Getting there faster".

OOP overkill is not good... But using OOP smartly ... Well... I'm really Glad I've left DBPRO, made a nice lib, and I bang on it alot.... the more I use it... the more solid the whole code base gets. It always makes it easy to roll out "Fixes" to many places at once (like a fix to the object factory if you find a flaw... fixes MANY apps that use it in one fell swoop)

How ya been making out lately?

Is anyone else writing OOP wrappers for their own games or generically? I wonder if you could write OOP shaders... and make a little "Code Lib" of shaders that weren't so... Write Once and go... hmm.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 19th Mar 2008 03:15
Quote: "Is anyone else writing OOP wrappers for their own games or generically?"


Only for 2D stuff at the moment and almost on an as needed basis. But that means that I try to do support for the entire concept, such as sprite, image and bitmap. I'll jump on memblocks at some point along with sound and music. But all I'm doing is duplicating the functionality that's there, which means calling the GDK functions with encapsulated numbers. I also store some information that you can get by querying GDK for the state of the sprite, image, etc. Dunno if this makes it run faster (a compulsive concern of mine) but it does run the risk of getting the stored info out of sync with the counterpart in the GDK system.

I've thought of adding some functionality but figure that's what inheritance is for. Yet there may be some things that can logically be added.

Lilith, Night Butterfly
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 19th Mar 2008 12:37 Edited at: 19th Mar 2008 12:37
Quote: "How ya been making out lately?"



Pretty good. I made a little Pong game with my wrapper that you can find by going to my threads. Unfortunately, I haven't been able to update the wrapper lately because I'm using my newfound knowledge of C++ to create a 2D Game Engine w/ DirectX. But I have spring break from school starting tomorrow, so I'll have some time to update it, add examples, and post the update.

@Lilith:

Sounds cool. I understand if ya don't want to, but if ya felt like posting your wrapper for everyone to take a look at that'd be cool.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 19th Mar 2008 13:20
@Lilith - Sounds like you're doing what I think many are.. even if they aren't posted here. I think Storing the infomation is a good idea, and also having a "Whoops...I did something I know hosed it" clean up routine might be good too or some variation.

What do I mean? I mean a routine you can call (but usually not needed) that queries GDK about the info you save, and updates your class' internal variables... basically to "Resync" with DarkGDK's view of the world for whatever it is your writing this routine for.

I did a variation on this idea that I now use and I like becauase it centralizes stuff for me - so far I've REALLY only implemented it for my Camera class, and also my userinput class (mouse only so faR).

Basically, I have a bunch of properties I just make public variables, and I prefix them with pvt_... This way I can acess them as fast as a Variable (Speed one of my concerns also) but I know I shouldn't write to it from the same. ("Honor System" LOL).

So for the camera I DO NOT store most information (Except FOV) HOWEVER, each Loop, I call an UpdateRoutine that populates the camera X,Y,Z, XA,YA,ZA, Distance Travelled Since Previous Call, Previous X,Y,Z,XA,YA,ZA. Yup... I save all that... BUT then .. In MY Programs, I'm not needing dbCameraPositionX() etc... Plus... usually I found I might get lazy and have the same call here and there... and this technique eliminiates that. I Call the "Where Are You Camera" functions in DarkGDK ONCE... then just reference the info it gathered. Overall I believe this is a good optimization and organization thing.

The Mouse works the same way. I store the x,y,z and claculate my own MoveMovedX, MouseMovedY, MouseMovedZ, Gather The Buttons too... I ALSO keep the PREVIOUS call's values... so I can test for:

if(mouse->pvt_Button1Old == false && mouse->pvt_Button1 == true) {
I know the button state changed LOL
};

Keep up the good work! Let us know how this 2d gdk lib you're making is working out and if its helping ya or not!


@Andrew - Can't wait to see wht you do with a little time on your hands.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 19th Mar 2008 22:58 Edited at: 19th Mar 2008 23:27
Quote: "@Lilith:

Sounds cool. I understand if ya don't want to, but if ya felt like posting your wrapper for everyone to take a look at that'd be cool."


I expect at some point I will share it at the expense of my self-esteem.

I've mentioned this before, probably in another thread. I had some bit of a problem in that the way I program generally means instantiating at least a few items as globals. But since the support for the GDK isn't available until the DarkGDK() function is called I was building in too many checks for validity that in the long run probably doesn't slow things down too much but leaves too much room for not checking for it where I need it. Because of that I've removed most of the checking from my classes and implement my program by creating a game class with the objects I need as a part of the class. That essentially makes them global to the rest of the program because every part of the program is part of the same class. I then instantiate an object of the game class (cleverly called DarkGame)inside the DarkGDK() function and call its Run() function.

So my classes might be useful but one would have to get used to this type of approach. I know that PopCap uses this approach in their SDK but I never really got a feel for how to use it until I kind of worked it out for myself with their inspiration.

Lilith, Night Butterfly
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 20th Mar 2008 06:29
@Jason

Just a quick mention......

I spent a little time looking at part of your code, specifically the bitmap class and I see a difference in our approaches, though it's really a matter of to each his own. The approach I've taken is to blend the functionality of the 2D operations into the bitmap class and will probably do the same for the image class once I have a bit of time to get past the basics.

Example:



The same for the circle and box functions. The Line() function sets the bitmap number associated with Background as the current bitmap and calls the dbLine() function. My bitmap class also sets and stores foreground and background colors and invokes dbInk(fgclr,bgclr) before the drawing function is called. An overloaded function may carry an override as to the color to be used without changing the defaults for the bitmap.

Though not part of the GDK concept in general I've also implemented such things as a struct called point that carries the x and y co-ordinates along with some overloaded operators.



Overloading the Bitmap::Line() function I can do something like:



This may be a bit of overkill but it's the way I've been brought up to think of objects. Then nice thing is that you can define and include classes out the wazzoo in your code but if you don't instantiate an object of the class it doesn't take up any room.

Lilith, Night Butterfly
MrSnowman
17
Years of Service
User Offline
Joined: 23rd Jun 2007
Location: Oregon, USA
Posted: 20th Mar 2008 08:52
AndrewT, I just checked out your OOP wrapper and I'm really reallly liking its simplicity! I'm relatively new to programming ~1 year and this is really helpful. I find OOP easier to work with than procedural. Thanks

jason p sage, I downloaded your but haven't worked with it much yet. I'll probably post again.

"He's got them on the list - he's got them on the list; and they'll none of them be missed - they'll none of them be missed."
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 20th Mar 2008 12:45 Edited at: 20th Mar 2008 14:23
@Lilith - Neat. Good ideas. The reason I did things how I did was to basically organize and modularize the DarkGDK existing stuff. I like your approach also.

I haven't put alot of work into the BitMap class as yet... Though images and this special class I call the PixelGrid is probably closer to how you work.

The Pixel grid is basically a Memblock you can make images from or too... and has various functions like pasting one image into another at speicifc coord's or whatever... no scaling or true blending yet... but I'm getting there slowly but surely. This is going to be one of the work horses in my Iron Infantry's Editor for things like shadow burn in and texture blending - at least that's the plan LOL


[edit]
@MrSnowBall - Let me know how you make out... I MAY have a new "release" for it this weekend, as that PixelGrid Class has made some strides, and I want to allow people to be able to set defaults in a config source file - and allow turning off Sparky and DarkPhysics Support easily... Though I think after that I might get source code shy as I'm starting to get to the point where the GAME code is starting to be written here and there... and The lib will be generic NOW but will eventually start having a slant towards Iron Infantry.

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 20th Mar 2008 15:30
@ Mr Snowman:

Thanks for checking it out!! It's good to know that I'm helping somebody.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 20th Mar 2008 16:54
Quote: "@Lilith - Neat. Good ideas. The reason I did things how I did was to basically organize and modularize the DarkGDK existing stuff. I like your approach also.

I haven't put alot of work into the BitMap class as yet... Though images and this special class I call the PixelGrid is probably closer to how you work.
"


It is a matter of six of one.....etc. There is a point at which you have to determine what's basic functionality and what's specific to a specific purpose. That's what's so nice about inheritance, the functionality in a can that you're able to add more to. For my current project I have a class derived from the bitmap class I simply call Grid. At the moment it's doing all of the work and doesn't need to borrow the drawing functions from somewhere else.

I'll be interested to see what comes of your PixelGrid. I may go in that direction myself but find that some of the functionality that's built into the 2D options are going to take some extra thought. I had a need to create a rainbow last week and I used the Circle function with the bitmap to draw gradiated circles then plastered a white box over the bottom half. One of the problems I ran into was that with integer radii it causes some white (background color) gaps due to rounding. So I decided to write my own "Arc" function to allow me to do portions of circles with real radii. It didn't work out very well.

Lilith, Night Butterfly
prototype angel
16
Years of Service
User Offline
Joined: 21st Mar 2008
Location:
Posted: 21st Mar 2008 13:22
AndrewT, I'm not able to use your library for my 2d game. Can you tell me how to fix this error:

1>LINK : fatal error LNK1104: cannot open file 'SC_Collision.lib'

also sometimes SC_Collision.h cannot be opened.

This is my code for a basic object oriented library for my game:


I've used a different system where the Sprite's fundamental variables are exposed as public, and a "handle" function updates all the variable and performs the nesaccary tasks. Also a trajectory class enabling the sprite to move along a specified direction is available.

Should I go ahead writing the library for my own needs or can I reuse your code. I don't have darkphysics.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 22nd Mar 2008 19:21 Edited at: 22nd Mar 2008 19:34
Quote: "1>LINK : fatal error LNK1104: cannot open file 'SC_Collision.lib'"


That error is because you don't have Sparky's Collision. I'm gonna post an update in a minute or so that allows you to disable it if you don't have it.

::EDIT::

K, I've updated the post with a version that doesn't require Sparky's. If you do want to use it, just put...



...at the top of your code.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 7th Apr 2008 06:47
Hello Everybody. I JUST RELEASED the latest version of My DarkGDK OOP Library. It can be found here: http://code.google.com/p/darkgdkoop/

Many enhancements, more solid ID generation, new PIXELGRID class for manipulating images in memory, and much more.

You'll need to download both files in the downloads area - they go together. Full source code and Media included.

check out the readme file for details here:
-----------------
README FILE BEGIN
-----------------

-----------------
README FILE END
-----------------

Ghthor
16
Years of Service
User Offline
Joined: 5th Apr 2008
Location:
Posted: 7th Apr 2008 10:20
@Jason

I'm new to programming, but I'm a computer nerd. I know doesn't make any sense. It just never dawned on me to get into the programming aspect. But so far coding and me are off to a wonderful start, I've picked c++ up in about 3 months and I'm well on my way to building a multi threaded OOP game engine from all this great stuff in the GDK.

One thing I haven't spent much time on is figuring out all the stuff that VStudio does for me and currently heres my problem.

I can't work with <string> classes in my GDK wizard created projects.

Heres the Linker Errors I have


Thanks for your code, its been giving me wonderful Ideas of the things I can do. I will post some things in this thread once My newbie status on the forums is over with.

Taco Justice
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 7th Apr 2008 14:34
@Ghthor -
Quote: "I'm new to programming, but I'm a computer nerd. I know doesn't make any sense. It just never dawned on me to get into the programming aspect. But so far coding and me are off to a wonderful start, I've picked c++ up in about 3 months and I'm well on my way to building a multi threaded OOP game engine from all this great stuff in the GDK."

AWESOME!

Quote: "One thing I haven't spent much time on is figuring out all the stuff that VStudio does for me and currently heres my problem."

Well, I'm no expert here but I know for a fact there are many threads in this forum for linker errors. (This is where I go when I hit a road block)

Quote: "Thanks for your code, its been giving me wonderful Ideas of the things I can do. I will post some things in this thread once My newbie status on the forums is over with."

Awesome! Glad to hear it! I released it for people like you!

I'm curious how you're going about the multi-threaded stuff in C++. Care to share? What WinAPI calls are you making? Are you making critical sections for interprocess communication or doing some other stuff for this? What are you using various threads for?

@Andrew - Glad to see you here man! This thread Will not die! (at least in the short term )

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 7th Apr 2008 18:21
Quote: "I can't work with <string> classes in my GDK wizard created projects."


That seems to be true regarding anything in the std namespace until.....

When you're programming in debug mode and including anything in the std namespace you need to remove the debug version of the multithreading library. To do this you go to the project properties and under Configuration Properties/"C/C++"/Code Generation change the /MTd to /MT. I believe this is because there is no debug version of the GDK code. You normally don't have this problem in the Release version.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 7th Apr 2008 23:17 Edited at: 8th Apr 2008 00:27
Although I've developed a few other classes, I feel that the manner in which they're interrelated makes it difficult for me to release until I'm a bit further along and tested with all of them. However, one class that I've created, though may have more to add to later, isn't so dependent on other classes and thus ready for prime time.

I'm attaching a zip file with the essentials of my Mouse class. Hopefully the text and the sample main.cpp will explain it in sufficient detail so I won't go into it at length. The reason I wrote a Mouse class is that, though I had a workaround for the problem of getting a button-down status rather than a single click status from the GDK, I ended up having to duplicate the code in odd places. It also meant keeping a global variable to account for the state of each button. So I created this class instead. It also afforded me the ability to move sprites with the mouse without really intense code.

If you want to use this, please make sure you read the caveat at the end regarding where and/or how to implement it within your own program structure.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Attachments

Login to view attachments
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 8th Apr 2008 00:00 Edited at: 8th Apr 2008 00:11
Quote: "What you sound like your describing is REAL "Properties" where it acts like a variable - when you set it or read it - it does the stuff I did under the hood but "SEEMS" like a variable directly.

Mouse->Visible=false;

or

Mouse->Visible=true;"


I'm a bit late to this conversation and I admit that I haven't followed it completely but that's never stopped me from opening my mouth before. Niels is coming from a .NET perspective albeit in VB which is most unfamiliar to me. What he's doing there isn't possible in C++ but it is possible in C#. If memory serves, in C# it's something like.




Mind you, this is from memory and it's been months since I've dipped into C#. It all comes down to the same thing you'd be doing in C++ but with a wrapper around it that makes it look like a variable when in fact it's more like a function call that lets you accomplish more. If you did something like

mouse.visible = false;

in C++ to a variable all it would do would be to change the variable. By intercepting it with the function call you not only set the variable but also hide or show the mouse at the same time. Protecting the user isn't the only use for this functionality.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 8th Apr 2008 00:17
In C# its



Niels Henriksen
Working on a (MMO)RPG right now in LightEngine (thanks kBessa): www.tales-of-the-realms.com
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 8th Apr 2008 00:23
That's my main tripping point in C#, remembering to mark each entities accessability.

BTW, I'm sorry to have gone back to an old subject. One of the refreshes took be back to the first page and I took it to be a discussion that was more recent but that I had skimmed over.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Apr 2008 00:38
No problem revisiting OLD stuff here - this thread is about OOP programming and ALL that implies! Like... why do they call it an object if its not physically Tangible? See? All goes in this thread!

Now as regards the statement
Quote: "What he's doing there isn't possible in C++ but it is possible in C#. "
I am forced to disagree in principal but agree 100% in practicality.

You most definately can do the same thing in C++ but it requires operator overloading, and some very ugly code to accomplish it.

http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4031/

About your mouse class, you stated the same reasons I wrote mine. "One Stop Shopping" to put it briefly. Much less complex to work with. Good Show Lilith!

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 8th Apr 2008 00:51 Edited at: 8th Apr 2008 00:52
Quote: "and some very ugly code to accomplish it.
"


Heh, heh!! You spelled "hideous" as "ugly."

Gawd, I haven't been to Code Guru in a long time. But I do make multiple stops at Code Project daily.

One of the things, and I think I may have mentioned it here before, is that my Bitmap, Image and Sprite class objects all return their numeric equivalent when referenced by name. When I looked into it (I knew it could be done but had to re-learn how) I was warned that it was not a recommended way of doing things. But in the context of Dark GDK it makes sense and I'll continue to use the technique until something break. And it's not ugly. Just dangerous.

As to my Mouse class, having read that old item I went ahead and added the visibility functionality but haven't updated it here. At some point I'm probably going to have to create my own graphical cursor so it will come in handy.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Apr 2008 00:58
Referenced by name? Hmm. Wonders how this accomplished.. simply naming each class, an array index'ish lookup of name value pairs, a double linked list, hmmm...

Your Sig
Quote: "I'm not a programmer but I play one in the office"
Me TOO! What line of work.. if you care to say. I'll go First: CRM Systems - which? Name it and I probably work with it or compete directly with it. Oh I wrote my own too but I don't have the where with all to really market it just yet. Maybe someday - when people want something that is unneccarily complicated, connects to any data source or "business logic connector" easily, and don't mind stepping slightly away from MicroSloth. (Yeah it works with Microsoft, but it works even better on Linux and Max and HP UX (Unix) etc.

Ghthor
16
Years of Service
User Offline
Joined: 5th Apr 2008
Location:
Posted: 8th Apr 2008 01:22
I've Attached the class I'm using for creating and using threads. I didn't create this I found it on codeproject I believe, can't remember anymore.

Theres a readme in there and it has useful comments. Don't forget to
look at the Thread.h file. If you have any questions about it I'll try and help out, but all in all its straight forward.

Taco Justice

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-09-29 23:19:05
Your offset time is: 2024-09-29 23:19:05