Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Nov 24, 2017 2:36 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Mon Mar 15, 2010 3:41 pm 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
Here's how this "Games" forum is described:

Quote:
Working on an RB3D application and have questions? Wondering how the SpriteSurface is used?.... Look no further, you can ask all your game-related questions here.
http://forums.realsoftware.com/

Well, I have questions that involve both RB3DSpace and Sprite Surface.

Under "Deprecated Items" in the latest RB Language Reference, it says this:

Quote:
Items that have already been removed from REALbasic have no hyperlinks in the following table.

In that table, RB3DSpace and SpriteSurface have no hyperlinks, which apparently indicates that RB3DSpace and SpriteSurface "have already been removed" from REALbasic.

Following is REAL Software's current description of Real Studio Personal Edition:

Quote:
REAL Studio is a great way to hone your critical thinking skills while you develop software games. Create strategy games, visual games, even action games. All you need is a cool idea and REAL Studio to get started!
http://realsoftware.com/realbasic/personal.php

Three questions:

(1) If RB3DSpace and SpriteSurface have been removed from REALbasic, what is the purpose of this forum (see forum's description above)?

(2) Without RB3DSpace and SpriteSurface, is it still possible for you to "create strategy games, visual games, even action games" with REALbasic?

(3) What are game programmers here planning on doing? If REALbasic is dropping support of game programming, what are people here planning on using to write games?

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Mon Mar 15, 2010 8:34 pm 
Offline
User avatar

Joined: Thu Mar 05, 2009 1:03 pm
Posts: 1786
Location: USA
barrytraver wrote:
Here's how this "Games" forum is described:

Quote:
Working on an RB3D application and have questions? Wondering how the SpriteSurface is used?.... Look no further, you can ask all your game-related questions here.
http://forums.realsoftware.com/

Well, I have questions that involve both RB3DSpace and Sprite Surface.

Under "Deprecated Items" in the latest RB Language Reference, it says this:

Quote:
Items that have already been removed from REALbasic have no hyperlinks in the following table.

In that table, RB3DSpace and SpriteSurface have no hyperlinks, which apparently indicates that RB3DSpace and SpriteSurface "have already been removed" from REALbasic.

Following is REAL Software's current description of Real Studio Personal Edition:

Quote:
REAL Studio is a great way to hone your critical thinking skills while you develop software games. Create strategy games, visual games, even action games. All you need is a cool idea and REAL Studio to get started!
http://realsoftware.com/realbasic/personal.php

Three questions:

(1) If RB3DSpace and SpriteSurface have been removed from REALbasic, what is the purpose of this forum (see forum's description above)?

(2) Without RB3DSpace and SpriteSurface, is it still possible for you to "create strategy games, visual games, even action games" with REALbasic?

(3) What are game programmers here planning on doing? If REALbasic is dropping support of game programming, what are people here planning on using to write games?

Barry Traver

I'm pretty sure you're right about SpriteSurface (no idea about RB3DSurface); the non-updated forum description is probably a minor oversight on RS' part.
Game programmers, though, seem to be growing in strength here; check out recent threads on OpenGL. There's a nice community effort growing to create some FOSS, user-friendly, RB classes for OpenGL.

_________________
With great power comes great responsibility.
Learn something new every day, and the rest will take care of itself.
Life is a journey, not a destination. Enjoy the trip! :D


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Tue Mar 16, 2010 4:00 pm 
Offline

Joined: Mon Feb 05, 2007 11:35 am
Posts: 98
RB3D is going away due to the OpenGLSurface and built-in support for core OpenGL, which is why there's a large movement towards it.

You can also use the Canvas to create games. While it's not suitable for heavy action games (I recommend OpenGL for that), it can work for games that require less graphics horsepower (ie: word games, non-realtime strategy games, board games, etc.).

_________________
Regards,

Jeff Quan
jeff@jcquan.com
http://www.jcquan.com/JQportfolio
My RBGL replacement classes: http://www.jcquan.com/REALbasic


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Tue Mar 16, 2010 6:11 pm 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
Jeff and "computerfreaker,"

Thanks for the posts.

What I want to do is fairly simple: not fast-action arcade games with sprite collisions, but fairly slow-moving computer versions of board-game games with movable pieces. My ultimate goal is to port over my "Coney Games," which are more strategy-type. (Incidentally, many of them are based on Martin Gardner's past "Mathematical Games" column in Scientific American.)

2D is fine (I don't really need 3D). In fact, 2D is probably better for me than 3D, because I need something very simple.

I'm helped most if I have sample code. There are a couple of nice graphics programs in RB's example programs (one on buffering and one on drag and drop), but the code is too complex for me to make much sense out of it.

I'm not graphics-oriented, so if anyone can point me to a simple sample program, I would be very grateful. (I don't care whether the code makes use of the canvas control or OpenGL, as long as it's fairly simple to follow.) If I can just see how to do something like move a chess piece from one square to another on a chess board (either by drag and drop or by changing the coordinates), I should then be able to adapt that code to the other things I want to do.

Thanks again for the help.

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Tue Mar 16, 2010 6:29 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Quote:
If I can just see how to do something like move a chess piece from one square to another on a chess board (either by drag and drop or by changing the coordinates), I should then be able to adapt that code to the other things I want to do.

I think the DragPics example does most of what you need.


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Wed Mar 17, 2010 5:41 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
Tim Hare,

Quote:
I think the DragPics example does most of what you need.

Been there, done that, but I found little help in that example (the fault is not in the example but in my lack of professional expertise in programming).

The DragPics example is actually probably more than I need, but it's also more than I can understand. Here's an example of just a small part of the code:

for i = 0 to 25
size = 32+i*2
p = NewPicture(size*2,size,32)
if p = nil then
MsgBox "Out of memory. Please increase the RAM allocation to the IDE (or built app)."
return
end if

g = p.graphics
g.foreColor = RGB(100+Rnd*155, 100+Rnd*155, 100+Rnd*155)
g.FillRect 0,0,size*2,size
g.foreColor = RGB(0,0,0)
g.textSize = size*3/4
w = g.StringWidth(chr(65+i))
g.DrawString chr(65+i), size-w/2, size*3/4
g.DrawOval 0,0,size*2,size

g = p.mask.graphics
g.ClearRect 0,0,size*2,size
g.foreColor = RGB(64,64,64)
g.FillOval 0,0,size*2,size
'g.foreColor = RGB(0,0,0)
'g.DrawRect 0,0,size*2-1,size-1

The DragPics example is actually one of the two examples I referred to in a previous note (I think I called it a "Drag and Drop" example). The result is very nice, as I said, and very impressive, but it's not for the beginner, and I don't know how to adapt it so that it will, say, allow me to move a chess piece from one position to another on the screen.

I am NOT a professional programmer with training in computer science; I program for fun and my programs are sometimes interesting and/or useful (what I lack in technical expertise, I try to make up for with creativity, originality, and ingenuity), but they show that the gaps in my knowledge are sometimes rather large.

The DragPics example mentions a "NewPicture," but then it goes on to mention things like FillRect, TextSize, StringWidth, DrawString, and DrawOval that seem to have no relationship to moving a game-board piece (such as a bishop on a chessboard) from one location to another.

The DragPics example is very impressive to run, but to me it seems more an example of "look at what I can do" than it is an example of something from which a RB newbie in graphics can learn.

Barry Traver


Last edited by barrytraver on Wed Mar 17, 2010 5:47 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Wed Mar 17, 2010 5:45 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
P.S. I hope you can excuse this digression, but people are usually surprised by two things about me: (1) the things I know that they wouldn't expect me to know and (2) the things I don't know that they would expect me to know. (Unfortunately, the second category is larger than the first.)

I may be ignorant (lacking technical expertise in various areas, but I am not entirely unintelligent. Evidence of that is my induction into the TI99'ers Hall of Fame on April 11, 2005:

Quote:
Barry Traver is legendary in the TI99ers community. A prolific writer, his articles and programs about and for the TI-99/4A have been published in MICROpendium, Computer Shopper, 99'er Home Computer Magazine, The Smart Programmer, [and] Super 99 Monthly....

Barry's "diskazine" or magazine-on-disk, the Genial TRAVelER, which made its debut in August, 1985, was influential and very popular.... He has served as a Sysop on CompuServe's "TI Forum" and later as Bulletin Board Manager of the "TI RoundTable" on GEnie....

Barry was a frequent featured speaker at TI Faires in Boston, Chicago, Los Angeles, Milwaukee, Ohio (Lima), Ottawa, San Diego, Tucson, and elsewhere. Barry received recognition with a number of awards, including the John Birdwell Memorial Award at the Chicago TI Faire in 1991 and a similar award from the Ottawa, Ontario TI-99/4A Users Group. In June 1989, the Users Group of Orange County, CA (UGOC) elected Barry to their Hall of Fame.

Barry was instrumental in developing eXtended eXtended Basic (XXB). This added about 45 commands not available in normal Extended Basic. Barry also developed GRAPHICOMP (for GRAPHICs COMPiler)....

Barry pioneered what became the standard ARCHIVER program for the TI. He is especially known for his utility programs, such as GRAPHICOMP, and game programs such as "Giant and Dwarfs" and his "Coney Games" series, many of which were based on Martin Gardner's "Mathematical Games" column in Scientific American. CONEY GAMES ... was released in June, 1990.

http://www.ti99hof.org/bios/BarryTraver/BarryTraver.htm

It is those "Coney Games" that I want to port over to REALbasic. When I do so, I expect that I will (as is my usual practice) release them publicly ("for free," including source code) for anyone who may be interested.

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Wed Mar 17, 2010 11:55 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
The problem with your request is that it is a fairly complex operation. Not that it is difficult, just a lot of moving parts, so to speak. And on top of that, there are multiple ways to approach the problem. And your question is rather non-specific. So it's kind of hard to even know where to begin with an example. You need to break this down into smaller pieces.


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Wed Mar 17, 2010 12:37 pm 
Offline

Joined: Mon Feb 05, 2007 11:35 am
Posts: 98
Hi Barry, I noticed something with the code you've posted: where are the comments?
The DragPics example I see has a good amount of commented code.
You might have removed them for posting, but I just wanted to be sure you don't have some sort of comment-less version of DragPics.

What might help is if you opened up the Help menu's Language Reference as you're digging through the code -- I do it all the time. However, like Tim said, pick a smaller part of the puzzle and ask for help with that. Once you've got that piece, ask for help with another piece.

_________________
Regards,

Jeff Quan
jeff@jcquan.com
http://www.jcquan.com/JQportfolio
My RBGL replacement classes: http://www.jcquan.com/REALbasic


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Wed Mar 17, 2010 2:14 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Here's a simplistic example that may nudge you in the right direction. Put a canvas on a window and add the following properties to the window:

pic as Picture
picX as Integer
picY as Integer
mX as Integer
mY as Integer

In the Open event of the window put
// create an image to drag around.  Very simple, just a green square.
pic = new picture(40,40,32)
pic.graphics.ForeColor= &c00ff00
pic.Graphics.fillrect(0,0,40,40)

// initial position for the image
picX= 10
picY= 10


In the Paint event of the canvas put
g.DrawPicture pic, picX, picY


In the MouseDown event of the canvas put
// determine if the user clicked on the image
if x< picX then return false
if x> picX+ pic.Width then return false
if y< picY then return false
if y> picY+ pic.Height then return false

// the mouse is inside the image, record the current position...
mX= X
mY= Y
// ...and enable dragging
return true


In the MouseDrag event of the canvas put
if x= mX and y= mY then return

// adjust the picture location by the amount the mouse moved
picX= picX+ X- mX
picY= picY+ Y- mY

// save the current position
mx= X
my= Y

// redraw the canvas to show the image at the new location
me.refresh


You should be able to click on the square and drag it around the canvas.

HTH,
Tim


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Wed Mar 17, 2010 7:20 pm 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
Jeff,

Yes, I did take out the comments for three reasons:

(1) They weren't necessary to make my point about FillRect, TextSize, StringWidth, DrawString, DrawOval. etc., all of which seemed to have little relationship to my desire to move something like a chess piece from one position to another position on the screen. (I do know how to use MS Paint to make a mask to go with a rectangular JPG picture of a chess piece, but that's about the extent of my knowledge of graphics.)

(2) It's embarrassing enough to admit that I can't make sense out of the DragPic code itself without having to admit that I can't make sense out of the code with comments.

(3) My posts were lengthy enough without making them even longer.

TIm Hare,

Thanks for the detailed example. The task is indeed more complex than I had realized, but the specifics in your note (to which I'll give more attention when I'm off-line) seem easier to make sense of than RB's DragPics example.

The Texas Instruments TI-99/4A computer with its TI Expanded BASIC language back during the "home computer wars" in the 1980's made it simple to create and move irregular-shaped sprites. In fact, a separate video chip made it possible to set the sprites in motion and have them continue in motion with no attention needed from the main CPU. Those were the days!

Back then possibilities like 3D graphics were unknown (even in assembly language; for a while I wrote a monthly column on combining BASIC and assembler for MICROpendium), but a sprite could be created in BASIC (or at least TI Extended BASIC, an enhancement of TI BASIC) with a simple CALL SPRITE command. We've gained power at the cost of losing simplicity.

If, however, I can get one RB example working (and for me 2D is fine), that should open the door to my porting over all of my Coney Games, whose strength is in logic, strategy, etc. rather than super-fancy and super-complex graphics. The rules for the Coney Games are simple and appear to favor the human (all of the games pit the computer against a human), but the computer (depending on the game) wins 95% to 100% of the time.

They are sort of like the more recent "shell game." Back in Elizabethan England, a "coney" was a rabbit (the "mark" in more recent terminology), and "coney-catching" was a term for a confidence trick (or "con game"?). Martin Gardner never uses those terms, but he does mathematically analyze such games, and thus making them into games on the computer seems a natural application.

If I can port them over, I expect (as is my usual practice) to release them publicly (including source code) for anyone who might be interested.

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Thu Mar 18, 2010 12:31 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
I played with sprites back in the 80's as well, on the TRS-80 and Commodore 64. The SpriteSurface would make some things easier, but it's more than you need. You can make a very passable sprite with a timer and a picture. I recently wrote a game for my son that wowed all his friends. I hear a lot of "you made THAT!?" The entire game is basically a timer and a picture (with a little data structure behind it to keep everything on track). The meat of any game is the data and how you keep it and how you manipulate it. What happens on screen is just a visual representation of the data.

In the DragPics example, the code you referred to with all the FillRect, DrawOval, etc., is just preamble. It's just there to set up some pictures to drag around. You'll notice that I did the exact same thing in my example. I just kept it to a single image for simplicity. You would replace all of that with actual images of chess pieces. The rest of the example has to do with taking a mouse click and determining which image, if any, was clicked and then moving it. You will do exactly that in a chess game. The main difference is that you'll want to snap the image to a grid when you drop it. But I think you will arrive at something very similar to that example when you're done.


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Fri Mar 19, 2010 5:11 pm 
Offline

Joined: Thu Feb 25, 2010 4:50 pm
Posts: 105
timhare wrote:
The entire game is basically a timer and a picture (with a little data structure behind it to keep everything on track). The meat of any game is the data and how you keep it and how you manipulate it. What happens on screen is just a visual representation of the data.


How do you get around the flicker that occurs in Windows that takes away from the "professionalism" of a solution? Following the numerous threads on this board I've reduced the problem, but not eliminated it.

RJL


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Fri Mar 19, 2010 5:22 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Turn off EraseBackground and always call Refresh(False). Render your entire canvas image to a picture that is the same size as the canvas and draw only that one image in Canvas.Paint. No other code in paint, just DrawPicture. Use a timer instead of a thread to do animation.


Top
 Profile  
Reply with quote  
 Post subject: Re: RB3DSpace, SpriteSurface, REALbasic game programming
PostPosted: Fri Mar 19, 2010 5:24 pm 
Offline

Joined: Thu Feb 25, 2010 4:50 pm
Posts: 105
timhare wrote:
Turn off EraseBackground and always call Refresh(False). Render your entire canvas image to a picture that is the same size as the canvas and draw only that one image in Canvas.Paint. No other code in paint, just DrawPicture. Use a timer instead of a thread to do animation.

I believe I am doing all of this....though I will confirm tonight. I will post back if it works. Thanks for the info. :)

RJL


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group