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 / Getting started with GDK, a basic question

Author
Message
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 15th Jul 2008 08:48
Hello, I'm a novice C++ programmer and I've been irritated at the lack of integrated graphics functionality in C++. I'd poked around at various graphics libraries, and toyed with just leaping straight into learning DirectX, but then I stumbled across Dark GDK and decided to give it a whirl.

What a wonderful thing you've created! It's so easy. I've just been reading the documentation and trying out commands, but I really like it so far. I set up a program to scatter random dots of random colors across the screen, and it was so easy. 2d graphics don't look like they'll be too difficult. 3d might take a bit of fiddling to get figured out...

Anyway, I do have a couple questions.

First, I'm trying to simulate regular C++ text output and input. Why? Because I want to that's why.

I can get it to display any text I want, in any color, in any location, just fine.

But I can't get it to accept input. The DBInput function doesn't seem to do what I want. I'm starting simple - I just want to be able to have the screen say "Input Number: " and have the user type in a number. Then I was going to spit out that number to a different location on the screen.

(This isn't just an arbitrary exercise - if I wanted to set up a scrolling chat window, for instance, I'd need something quite similar to this.)

But while I can use either the dbPrint or dbText to do standard text display, I can't seem to figure out how to accept user input. The only commands I can find for user input seem to be expecting data no more than one character long, and with no enter key to enter them in -- just keypresses. Am I missing something?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 15th Jul 2008 17:30
Quote: "I've been irritated at the lack of integrated graphics functionality in C++"


C++ is a language, not an API. Basic doesn't have integrated graphics, nor does COBOL or any of a number of languages.

AAR, have you looked at dbText (x, y, char*)?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 15th Jul 2008 17:38
Yes, and I can use it to output a string like this:

dbText(0,0,"Hello World";

Easy as pie.

But I can't get it so the user would type in "Hello World" or some other string.

That is to say, in very rough terms, I can use
dbText(0,0,"Hello World";
as a fancy, graphical version of
std::cout << "Hello World";

What I can't figure out is how to get user input strings, that is, a fancy, graphical version of
std::cin >> userString;


I know it's kind of silly and backwards to use Dark GDK to simulate a console window, but I'm pretty much just messing around and learning the commands, and this is the first thing I've tried to do and not been able to figure out.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 15th Jul 2008 17:47
Sorry, I looked at the wrong part of the only piece of code I've written to do this. And it's kinda kludgy looking but seems to work.



If you ignore the screen writes and the prompt setting the core of the input is the strcpy (filename, dbInput()) statement that essentially calls dbInput() which gets your input while echoing to the display. The character pointer to the input is passed to the strcpy() function which copies the text just input into the filename buffer which is then used to output the name of the file elsewhere. The rest of it is pretty much blanking out the text left over by the input process.

However, based on a previous discussion it seems that when you do dbInput () it uses dynamically allocated memory and you need to delete[] the allocation once you're finished with it.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 15th Jul 2008 17:53
OK, I'll have to try that.

(by the way, my previous post was in response to your first post, and this is in response to your second one. I'm still on the n00b delay. )
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 15th Jul 2008 17:56
Quote: "(by the way, my previous post was in response to your first post, and this is in response to your second one. I'm still on the n00b delay. )
"


I know. But since I subscribed to mailback I got an email notification which prompted me to look for my mistake. I usually own up to my mistakes.

Unless there's money involved.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 15th Jul 2008 18:41
Another random question!

I'm making a sprite slide around a map. It's basically a little smiley face on a gray grid.

Here's the code I'm using to move it:


This successfully slides my smiley face up and down.

But I can't figure out how to get it to move right and left. I don't really want to rotate it - just slide it around. But the MoveSprite function only seems to allow for movement along a single axis.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 15th Jul 2008 20:17
rotate it, move, then rotate it back before the screen updates
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 15th Jul 2008 21:46
Thank you jezza, that makes perfect sense now that I think about it.

Except I can't seem to get it to work right. Here is the code I'm trying to use:


The only other issue I'm having with this little project is that when I rotate the smileyface, the point of rotation is the upper left corner of the image -- so it doesn't stay put when it rotates, it spins around its corner.

Sorry if I'm bugging you all, I'm just having a lot of fun figuring stuff out.
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 15th Jul 2008 21:47
oooh, I have to use dbOffsetSprite, don't I?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 15th Jul 2008 21:51
Why not just use dbSprite() to position the sprite where you want it? Aside from the fact that I use my sprites through a class that keeps track of the sprite position, you can use the dbSpriteX() (& Y) functions to get the sprite position and move it.

dbSprite (1, dbSpriteX() + 1, dbSpriteY() -1, 1);

or whatever.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Merak Spielman
16
Years of Service
User Offline
Joined: 14th Jul 2008
Location:
Posted: 15th Jul 2008 22:30
Guess I was overthinking it, that works perfectly.
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 19th Jul 2008 07:14
Quote: "Sorry if I'm bugging you all, I'm just having a lot of fun figuring stuff out. "


HAH.


this is all completely voluntary. i dont think even the noobiest questions bother the people here.

we might ignore some of them though

~you can call me lantz~
Azeem
16
Years of Service
User Offline
Joined: 6th Jan 2008
Location: Metropolis
Posted: 19th Jul 2008 14:52
haha lol
i had the same problem, thanks for the easy fix!
at first i also mirrored my image because it was facing left
i had to go through alot of code before just using a simple solution and making a new graphic for the left faced sprite and coded that to have the same x,y coordinates as the right faced sprite. Kinda Easy really.

Azeem - Game Programmer In Training... knows php,html,mysql,js,ajax a little Action script and a little C++

Login to post a reply

Server time is: 2024-11-20 17:26:05
Your offset time is: 2024-11-20 17:26:05