Graphics mode

Hi all! I’m a beginner.

I need to include graphics mode in my program, I dunno how. I can do it
in C++, but I can’t in Ruby.
Example: a ball falls down. Da program calculates it’s coordinates and
it works. But I wanna see it. For now I can see just an array of (x,y)
values. Help me to make a graphic view using theese coordinates. In C++
I know I need just to initialize graphics mode. But I’m really green how
to do it in Ruby.

Help!

Teodor C. wrote:

Hi all! I’m a beginner.

I need to include graphics mode in my program, I dunno how. I can do it
in C++, but I can’t in Ruby.
Example: a ball falls down. Da program calculates it’s coordinates and
it works. But I wanna see it. For now I can see just an array of (x,y)
values. Help me to make a graphic view using theese coordinates. In C++
I know I need just to initialize graphics mode.

C++ has nothing like that – there is no such thing as “graphics mode”.
Perhaps you’re using a particular graphics library?

But I’m really green how
to do it in Ruby.

Help!

Same way as in C++: find a graphics library you like, learn to use it.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Wed, Dec 2, 2009 at 3:16 PM, Teodor C. [email protected]
wrote:

Hi all! I’m a beginner.

I need to include graphics mode in my program, I dunno how. I can do it
in C++, but I can’t in Ruby.
Example: a ball falls down. Da program calculates it’s coordinates and
it works. But I wanna see it. For now I can see just an array of (x,y)
values. Help me to make a graphic view using theese coordinates. In C++
I know I need just to initialize graphics mode. But I’m really green how
to do it in Ruby.

Initialize graphics mode?

C++ doesn’t have a way to “initialize graphics mode”, but some
library, provided by the system or a 3rd party will do so.

Unsurprisingly, you need a library to do the same in Ruby.

What library are you using when you do this in C++?

You could use a similar library in Ruby - Rubygame? Ruby/SDL?

Help!

Posted via http://www.ruby-forum.com/.


Paul S.
http://www.nomadicfun.co.uk

[email protected]

C++ doesn’t have a way to “initialize graphics mode”

Well, this is the way I do it in C++:

#include <graphics.h>
void main(){
//initializing graphics mode
int gdriver=DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, “C:\Progra~1\BORLANDC\BGI”);
errorcode = graphresult();
if(errorcode!=grOk) {
cout<<“Graphics error!!!\n”
<<“Press any key…”;
getch();
exit(1);
}
//…
//AND HERE IS DA MAIN PROGRAM CODE.
//…
}

I’d like to make my ruby prog like this. Any Ideas?
P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I’m really green. Plus, I use Ubuntu, no comment.

Thanks!

Teodor C. wrote:

C++ doesn’t have a way to “initialize graphics mode”

Well, this is the way I do it in C++:

#include <graphics.h>

Where did you get this header? What does it contain? I don’t think
this is standard in C++.

But we’re getting off topic.

void main(){
//initializing graphics mode
int gdriver=DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, “C:\Progra~1\BORLANDC\BGI”);
errorcode = graphresult();
if(errorcode!=grOk) {
cout<<“Graphics error!!!\n”
<<“Press any key…”;
getch();
exit(1);
}
//…
//AND HERE IS DA MAIN PROGRAM CODE.
//…
}

I’d like to make my ruby prog like this. Any Ideas?

Yes. Please read my earlier posts.

P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I’m really green. Plus, I use Ubuntu, no comment.

What is that supposed to mean?

Thanks!

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Same way as in C++: find a graphics library you like, learn to use it.

ok, I’ll try to find it. I use NetBeans, could you drive me step by
step?

Thanks!

On Wed, Dec 2, 2009 at 3:49 PM, Teodor C. [email protected]
wrote:

if(errorcode!=grOk) {
I’d like to make my ruby prog like this. Any Ideas?
P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I’m really green. Plus, I use Ubuntu, no comment.

I’m really confused.

You use Ubuntu, but you have a C:\ drive?

You use ubuntu, and therefore have access to gcc, but use the Borland
compiler instead?

I think the best thing is for you to forget this ‘graphics mode’ and
instead look at a library like rubygame.

Thanks!

Posted via http://www.ruby-forum.com/.


Paul S.
http://www.nomadicfun.co.uk

[email protected]

Teodor C. wrote:

Same way as in C++: find a graphics library you like, learn to use it.

ok, I’ll try to find it. I use NetBeans,

Your IDE is irrelevant. (But consider abandoning NetBeans and using
something like KomodoEdit.)

could you drive me step by
step?

No. That’s not what this list is for. If you need that kind of
handholding, buy a book.

Thanks!

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Your IDE is irrelevant. (But consider abandoning NetBeans and using
something like KomodoEdit.)
No. That’s not what this list is for. If you need that kind of
handholding, buy a book.

well, well, it is truly offensive, but it makes me go stronger and
further.

and… I’m not gonna buy ANY books.

“The best friend for you is yourself” (Louis Armstrong)

Thanks!

On Wed, Dec 2, 2009 at 10:49 AM, Teodor C.
[email protected] wrote:

I use Ubuntu

Google: “ruby graphics”:
http://www.greaterbostonrubyandrails.com/RubyGraphics.html

unknown wrote:

On Wed, Dec 2, 2009 at 10:49 AM, Teodor C.
[email protected] wrote:

I use Ubuntu

Google: “ruby graphics”:
http://www.greaterbostonrubyandrails.com/RubyGraphics.html

THANKS!

On 2009-12-02, Teodor C. [email protected] wrote:

Well, this is the way I do it in C++:

Uh.

#include <graphics.h>

This header is not part of standard C++. It’s a library provided
by your compiler.

void main(){

This is wrong too. main() returns int. If your compiler isn’t giving
you a warning for that, you should probably set it to be more
aggressive.

initgraph(&gdriver, &gmode, “C:\Progra~1\BORLANDC\BGI”);

You should be using forward slashes (they work fine on Windows in file
names) and full names, not the weird DOS-style names, in all
probability.

   getch();

This function exists only in a non-standard library you haven’t referred
to, and shouldn’t be getting used here anyway. If you need to make a
program
wait for a user to hit a key before exiting, you have done something
else fundamentally wrong.

P.S.: If you have an idea, please describe it in a way you would talk to
a noob, for I’m really green. Plus, I use Ubuntu, no comment.

I would recommend that you look into one of the existing graphics
libraries
provided by the environment. You’ll note that the program described
above
doesn’t work on your Ubuntu system.

There’s a bunch of graphics libraries out there. It matters a fair bit
what
you want, but some people have suggested gosu:

Google Code Archive - Long-term storage for Google Code Project Hosting.

-s

On 2009-12-02, Teodor C. [email protected] wrote:

and… I’m not gonna buy ANY books.

Why not?

“The best friend for you is yourself” (Louis Armstrong)

He’d be a better friend if he bought you some books to help you learn
faster.

-s

Seebs wrote:

On 2009-12-02, Teodor C. [email protected] wrote:

and… I’m not gonna buy ANY books.

Why not?

Well, to be fair…I usually have a similar attitude. Between the rapid
change velocity of things like Rails and all the free info out there, I
don’t usually need the books.

But with that choice come certain consequences, such as lack of
handholding. I have chosen to accept those consequences. People who
don’t want to accept those consequences should not make that choice.

“The best friend for you is yourself” (Louis Armstrong)

He’d be a better friend if he bought you some books to help you learn
faster.

-s

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Thu, 03 Dec 2009 00:49:57 +0900, Teodor C. wrote:

if(errorcode!=grOk) {
I’d like to make my ruby prog like this. Any Ideas? P.S.: If you have an
idea, please describe it in a way you would talk to a noob, for I’m
really green. Plus, I use Ubuntu, no comment.

Thanks!

Wow! That’s a blast from the past! I’m guessing it’s either Borland C++
for DOS (where screens actually did have “graphics mode” versus “text
mode”[1]) or their library for Windows which simulated the old DOS
library by opening up a window and drawing in that window. (I programmed
for this emulation library 10 years ago as part of an AP computer
science
assignment.)

I’m guessing that you’re moving from your knowledge of old DOS/Windows
and C++, you’re moving to Linux and now you want to learn a nice shiny
new language for programming in Linux, so you chose Ruby.

If you’re planning on writing GUI applications, you should either look
at
Ruby/GTK+ or QTRuby, both of which are good frameworks providing all of
the standard widgets that you find in word processors, web browsers, and
the like.

http://techbase.kde.org/Development/Languages/Ruby

If you want full screen graphics (or full-screen graphics in a window),
which is often useful for game programming, you should look at Ruby/SDL.

http://www.kmc.gr.jp/~ohai/rubysdl.en.html

Ultimately you should take the time to learn a little of both.

[1] FWIW, Linux has this too, but you only think about it that way if
you’re writing an X server or programming in svgalib. For the most part
that view of the world is obsolete by about 20 years.

On Thu, 03 Dec 2009 00:49:57 +0900, Teodor C. wrote:

if(errorcode!=grOk) {
I’d like to make my ruby prog like this. Any Ideas? P.S.: If you have an
idea, please describe it in a way you would talk to a noob, for I’m
really green. Plus, I use Ubuntu, no comment.

Thanks!

What a blast from the past!

It ain’t Ruby, but you might be interested in the BOSS library
( Welcome To codedread )
which implements a bunch of the old Borland C++ libraries on top of the
modern SDL graphics library, if you plan to keep coding in C++.

–Ken

Ken B. wrote:
[…]

If you’re planning on writing GUI applications, you should either look
at
Ruby/GTK+ or QTRuby, both of which are good frameworks providing all of
the standard widgets that you find in word processors, web browsers, and
the like.
http://ruby-gnome2.sourceforge.jp/
Languages/Ruby - KDE TechBase
[…]

There have been several recent threads in this forum on GUI development
in Ruby, and I’d recommend reading them. I’m using JRuby and Monkeybars
for my one non-Rails project.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

assignment.)
Heh same here actually… 10 years ago API Compsci :wink:

On Wed, Dec 2, 2009 at 11:25 PM, Seebs [email protected] wrote:

   getch();

This function exists only in a non-standard library you haven’t referred
to, and shouldn’t be getting used here anyway. If you need to make a program
wait for a user to hit a key before exiting, you have done something
else fundamentally wrong.

Ah, nostalgia :slight_smile: I think it was from Borland’s conio, a very
well-designed library indeed. I missed it when I first moved to linux.

martin

On Thu, 3 Dec 2009, Walton H. wrote:

assignment.)

Heh same here actually… 10 years ago API Compsci :wink:

Eeek! I feel old. I did AP CompSci back 21 years ago. It was in
Pascal
then…

Matt