|
Post by joeschmoe on Jan 5, 2013 7:47:35 GMT -5
Happy New Year! Seems like the Old Year with less time and money and more bills...
My football game has been progressing nicely. Everything I want to be able to do with the playbook maker module has worked out almost perfectly. Except one thing (at the moment, anyway)...
I can draw my plays. After the play's drawn, I want to be able to make all the lines and stuff disappear and run the play.
I thought I could just use GLclear() to erase all GL drawing, then redraw the field and move the sprites. I guess not and probably is the way I'm using the clear statement.
I just put it at the beginning of the GL code block that I used to draw the field the first time. I could only find one example of parameters to put in the clear statement in somebody else's program (can't remember where). I think it's supposed to clear to random background color.
Maybe I'm just using it in the wrong place or the parameters need to be something else?
Bottom line, since I'm running long here:
How do you clear some GL drawing and then redraw?
Thanks.
|
|
|
Post by matthew on Jan 5, 2013 11:59:17 GMT -5
Well glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT) is usually used to clean the screen of OpenGL objects. SwapBuffers () or glFlush() (if you want to draw immediately to the screen) is used to draw the OpenGL objects on the screen. When you want to draw Sprites on the screen you'll need to use DrawText().
I'm currently working on an example which could show you how to solve your problem, I'll try to post it up later.
|
|
|
Post by joeschmoe on Jan 5, 2013 18:36:29 GMT -5
Thanks, Matthew.
I had used glClear(GL_COLOR_BUFFER_BIT), so added the " or GL_DEPTH_BUFFER_BIT" but I just must be using it in the wrong place or something.
Just now, I added SwapBuffers() after the clear statement. It did clear the lines and redraw the field but with a lot of flicker (seems like a problem with my logic rather than GL but I haven't found it yet).
Actually, after running it a few times, seems to be more than one problem with the way I'm telling my sprites to do what I want, so I'll look at that code a lot better and rethink things.
Guess I better wait for your example, too.
|
|
|
Post by matthew on Jan 5, 2013 21:11:33 GMT -5
Okay the following program is based on the one I wrote in this post but with a small difference. When you press the SpaceBar on the keyboard, the line being drawn from Sprite to the Mouse will disappear. You could use the same technique in your game but instead of waiting for a button to be pressed, just wait for a few seconds before removing the lines. TextMode(TEXT_OVERLAID)
dim toggle, currMousePosX, currMousePosY, prevMousePosX, prevMousePosY
dim sprite = NewSprite(LoadTexture("data\ball.png"))
prevMousePosX = (windowwidth() / 2) prevMousePosY = (windowheight() / 2)
do
cls
printr "X: " currMousePosX print "Y: " currMousePosY
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glMatrixMode (GL_PROJECTION) glLoadIdentity () glOrtho (0, windowwidth(), windowheight(), 0, 0, 1) glDisable(GL_DEPTH_TEST) glMatrixMode (GL_MODELVIEW) glLoadIdentity()
currMousePosX = (mouse_x() * windowwidth()) currMousePosY = (mouse_y() * windowheight())
glPushMatrix() glTranslatef(currMousePosX, currMousePosY, 0) glColor4f(1.0, 1.0, 1.0, 1.0) glLineWidth(2.0) glBegin(GL_LINES) glVertex2f(-20, 0 ) glVertex2f( 20, 0 ) glVertex2f( 0, -20) glVertex2f( 0, 20 ) glEnd() glPopMatrix()
if not ScanKeyDown (VK_SPACE) and toggle = 0 then glbegin(gl_lines) glvertex2i(prevMousePosX, prevMousePosY) glvertex2i(currMousePosX, currMousePosY) glend() else toggle = -1 glbegin(gl_lines) glend() endif
DrawText() SwapBuffers()
SprSetPos(SpriteAreaWidth() / 2, SpriteAreaHeight() / 2)
loop
|
|
|
Post by joeschmoe on Jan 6, 2013 11:46:11 GMT -5
Thank you, Matthew.
If you modified this code to allow the user to, say, left click and "stick" the line drawn from the ball to mouse position, then continue it's operation and left click again to "stick" another line, then, say, hit spacebar (or whatever) to erase all drawn lines and start again...what would that code look like?
So far, I can draw the lines from a player to where I want him to go (mouse) and then draw another line from the end of the first line to where I want him to go as a second instruction. I can even cycle through different players and return to the original player and continue issuing assignments (another line segment or instruction) from the point of his last assignment. That part's cool and fairly easy (once you figure it out).
When I get all the players' assignments as I want them, then I want to restore the field, without any lines, and "run" the play with the player sprites generally moving to each waypoint in their assignment list.
So, far I've been able to do that from what you've explained to me. But, when I attempt to redraw the field to run the play, it becomes very dark and seems to flicker. And the sprites behave strangely, which makes me think it's my logic and probably not a GL problem, but I haven't had time to really look at it and think about it.
|
|
|
Post by matthew on Jan 6, 2013 16:42:53 GMT -5
I think we've gone about this the wrong way by using OpenGL graphics. :-) I remembered that Tom had made a new typeface for one of his games to create the on-screen menus. The same typeface could be used to draw your plays, I've made a simple example here for you to download and try. If you feel up to it, you could edit the graphics file and add some new symbols to the Font.
|
|
|
Post by joeschmoe on Jan 6, 2013 21:26:52 GMT -5
Thanks for those files, Matthew.
You may be right about another approach but I like the way the program works up until I try to run a play. I tried using sprites to make the lines but it was really awkward and didn't always work very well. I will have to use sprites to illustrate most of the assignments like blocking, etc.
Do you want me to send you the raw code file or make a stand alone on my wiki space so you can see what I'm trying to do?
|
|
|
Post by matthew on Jan 6, 2013 21:47:13 GMT -5
Just post a standalone on your Wiki so I can take a look. ;-)
|
|
|
Post by joeschmoe on Jan 7, 2013 19:38:08 GMT -5
I haven't created a standalone since I got a new computer. I keep getting this error:
"Error patching Basic4GL program into exe. Does not work on Windows 95, 98, ME...etc."
Any idea what I'm doing wrong? I'm using Windows 7.
|
|
|
Post by matthew on Jan 7, 2013 19:46:13 GMT -5
Hmm the error has been reported before on the Forum a few times. I recommend reinstalling Basic4GL and try creating the Exe again. If that fails, post back and we'll try something different.
|
|
|
Post by joeschmoe on Jan 7, 2013 19:59:21 GMT -5
Matthew, I may have just screwed the pooch on this one. When I reinstalled, the program files for the football game were gone, but some of my other programs were still there.
|
|
|
Post by joeschmoe on Jan 7, 2013 20:00:11 GMT -5
Never mind...they're back. Weird...
|
|
|
Post by joeschmoe on Jan 7, 2013 20:00:56 GMT -5
But I still get the same error.
|
|
|
Post by matthew on Jan 7, 2013 20:07:05 GMT -5
I know versions of Windows after XP have more Security because I used to use Vista. Do you Run Basic4GL on your Computer as an Administrator?
|
|
|
Post by joeschmoe on Jan 7, 2013 21:21:40 GMT -5
Bizarre.
When I run it normally, the program is available in the list. When I run it as admin, the program and all it's earlier versions are missing. But all my older programs are available.
Well, I opened it normally, loaded the program, opened a second B4GL as admin, and copied and pasted the stinking code in the admined editor. Seemed to work and made a standalone.
So...file name is "aapbk".
Some of the menus are disabled (or not even created). If your not sure what to do (help file is also not created) just mess around with it and let me know what screws up before you attempt to run the play (THAT is seriously screwed up).
Also, you can create any formation other than the ones I threw in by selecting a player and using arrow keys to move him around.
|
|