Qbasicnews.com
May 26, 2018, 02:41:45 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: 3D Chess Program in FreeBASIC  (Read 16309 times)
Sisophon2001
Member
*
Posts: 58



WWW
« on: May 06, 2005, 07:04:23 AM »

Hi:

I have uploaded a 3D Chess program, FBChess, using OpenGL and the GFX lib to my web site at http://weekendcode.phatcode.net This is a mixed BASIC program, with the front end in FreeBASIC and the chess engine in BCX BASIC.

It has a model loader for static Milkshape 3d Models and demonstrates one way to manage fonts in OpenGL. It uses the WinAPI for its ini file, for its file open/save dialogs, and for DOEVENTS, but I tried hard to minimize all window specific code so I could think about making a Linux version. I did all the buttons and menuís using font/graphics, so it would be independent of gui libs/dlls. The chess engine lib is in BCX but uses only generic code, nothing that will give problems porting.

I donít even have a computer with Linux installed yet, but there is a first time for everything <grin>. Can you run an exe on one of those CD bootable versions of Linux?

I may convert the rest of the BCX code to FreeBASIC at some stage, but I was struggling a bit with getting pointers to work in FreeBASIC, and I have enough of it for now. Besides it works fine as is.
 
Perhaps I might get a few hints on finishing the project by making a Linux version? All window specific code is in one source file for easy review.

Have fun

Garvan
« Last Edit: April 26, 2008, 10:42:36 AM by Sisophon2001 » Logged
rdc
Senior Member
**
Posts: 176



WWW
« Reply #1 on: May 06, 2005, 07:16:14 AM »

A very nice program. The link above doesn't seem to work though. This should:

http://www.freewebs.com/weekendcode/index.htm
Logged

Sisophon2001
Member
*
Posts: 58



WWW
« Reply #2 on: May 06, 2005, 07:36:43 AM »

Quote from: "rdc"
A very nice program. The link above doesn't seem to work though. This should:

http://www.freewebs.com/weekendcode/index.htm


Both work equally well here with WinXP Home and IE V6.0.

What is the best format to post links in so they work with all browsers, all systems?

Thanks

Garvan
Logged
VonGodric
Ancient Guru
****
Posts: 674



WWW
« Reply #3 on: May 06, 2005, 08:06:38 AM »

That\s really nice man! really!

but could you make board to be rotatble from mouse left button for example?
Logged

url]http://fbide.sourceforge.net/[/url]
steven_basic
Senior Member
**
Posts: 244


WWW
« Reply #4 on: May 06, 2005, 09:45:29 AM »

Quote from: "Sisophon2001"
What is the best format to post links in so they work with all browsers, all systems?


As you see Windows is very forgiving and IE tends to automatically translate "\" to "/" fo rthe user.  The standard would be to use forward slashes "/" and a connect type (http, ftp, etc) like so:

http://www.freewebs.com/weekendcode

All browsers should automatically look for "index.htm" and use it if it exists in the desitination folder.
Logged

ature has its way of warning a person away from danger:  The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Sisophon2001
Member
*
Posts: 58



WWW
« Reply #5 on: May 06, 2005, 10:08:01 AM »

Quote from: "VonGodric"
That\s really nice man! really!

but could you make board to be rotatble from mouse left button for example?


Thanks for your comments. This is a good idea and easy to implement. I just added support for rotating the board using the mouse, and will update the website this weekend.

Right button down and drag to rotate, and move up/down, wheel to zoom.

Have fun

Garvan
Logged
Sisophon2001
Member
*
Posts: 58



WWW
« Reply #6 on: May 06, 2005, 10:16:50 AM »

Quote from: "steven_basic"

The standard would be to use forward slashes "/" and a connect type (http, ftp, etc) like so:

http://www.freewebs.com/weekendcode

All browsers should automatically look for "index.htm" and use it if it exists in the desitination folder.


Okay I got it now.

Thanks

Garvan
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #7 on: May 06, 2005, 05:04:18 PM »

Pretty cool, the application stopped responding though, when i did an ambiguous move. No crashes, looks like it entered into an infinite loop.. XP Pro, SP2.
Logged

Mitth'raw'nuruodo
Ancient Guru
****
Posts: 515



WWW
« Reply #8 on: May 06, 2005, 05:28:52 PM »

worked fine for me, same hardware too.

was the square highlighted red when u tryed to move it?
if it was blue its not going to move

pretty cool
Logged

i]"But...it was so beautifully done"[/i]
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #9 on: May 06, 2005, 09:09:11 PM »

Looks cool,.. but it crashes on me,.. or is running really slow on my system... fyi: Win98 that acks like a DOS... Maybe I'll try again tomorrow after I let it repair itsefl tonight..  :wink: .. been draging.. >_<

^_^
Logged

Kevin (x.t.r.GRAPHICS)

Sisophon2001
Member
*
Posts: 58



WWW
« Reply #10 on: May 07, 2005, 05:15:10 AM »

Hi:

I have updated FBChess:

http://weekendcode.phatcode.net/


1. It is now possible to move and rotate the board by dragging with Right Mouse button down. The board can be raised/lowered using the mouse wheel.

2. I disabled the blue square for mouse input so that the user will have better feedback when the computer is not smart enough to figure out what he/she wants to do. Now it should be visible only when using the keyboard. I added logic checks to screen out invalid moves. I hope this helps with the problem reported by v3cz0r.
 
3. I added a pawn promotion dialog. The old keyboard method was unresponsive.

4. Added a warning to the web page to only use the program on a fast computer!

I tried FBChess on a 4 year old PIII running WinMe, and it ran 10 times slower than on my laptop (only 5 frame per second compared with 50). This a much bigger difference than I would have guessed. Perhaps it has to do with the OpenGL support in the hardware.

This is unusable as the user input is captured in the same loop as drawing the 3D models. It keeps skipping user input.

I donít see how you could improve this without changing the 3D models. Using events for user input would help, but it would still be slow. I will play around with it and see if I come up with anything.

Thanks for the feedback.

Garvan
« Last Edit: April 26, 2008, 10:44:03 AM by Sisophon2001 » Logged
VonGodric
Ancient Guru
****
Posts: 674



WWW
« Reply #11 on: May 07, 2005, 05:28:10 AM »

Could you release of it amodification with 2D interface -for older computer?

you could make 2 different UI modules -and link wichever user wishies while compiling. I guess underlying system is the same.
Logged

url]http://fbide.sourceforge.net/[/url]
VonGodric
Ancient Guru
****
Posts: 674



WWW
« Reply #12 on: May 07, 2005, 05:44:11 AM »

hey, I played i bit around in your code. here's small suggestion:
this code is in: FBChess.bas line 426

[syntax="QBASIC"]  IF (MOUSEB AND 2) and (MOUSE_X>-1) and (MOUSE_Y>-1) THEN
     
    IF OLDMOUSE_X > MOUSE_X THEN
      u = u - 0.01 * ( OLDMOUSE_X - MOUSE_X )
    ELSEIF OLDMOUSE_X < MOUSE_X THEN
      u = u + 0.01 * ( MOUSE_X - OLDMOUSE_X )
    END IF
   
    IF OLDMOUSE_Y > MOUSE_Y THEN
      y = y - 1.0 * ( OLDMOUSE_Y - MOUSE_Y )
    ELSEIF OLDMOUSE_Y < MOUSE_Y THEN
      y = y + 1.0 * ( MOUSE_Y - OLDMOUSE_Y )
    END IF
   
    IF OLDWHEEL > WHEEL THEN
      w = w - 0.5*2
    ELSEIF OLDWHEEL < WHEEL THEN
      w = w + 0.5*2
    END IF
  END IF[/syntax]

a bit easier mouse rotation handling  :wink:
Logged

url]http://fbide.sourceforge.net/[/url]
Sisophon2001
Member
*
Posts: 58



WWW
« Reply #13 on: May 07, 2005, 11:47:49 PM »

Quote from: "VonGodric"
hey, I played i bit around in your code. here's small suggestion:
this code is in: FBChess.bas line 426

[syntax="QBASIC"]  IF (MOUSEB AND 2) and (MOUSE_X>-1) and (MOUSE_Y>-1) THEN
     
    IF OLDMOUSE_X > MOUSE_X THEN
      u = u - 0.01 * ( OLDMOUSE_X - MOUSE_X )
    ELSEIF OLDMOUSE_X < MOUSE_X THEN
      u = u + 0.01 * ( MOUSE_X - OLDMOUSE_X )
    END IF
   
    IF OLDMOUSE_Y > MOUSE_Y THEN
      y = y - 1.0 * ( OLDMOUSE_Y - MOUSE_Y )
    ELSEIF OLDMOUSE_Y < MOUSE_Y THEN
      y = y + 1.0 * ( MOUSE_Y - OLDMOUSE_Y )
    END IF
   
    IF OLDWHEEL > WHEEL THEN
      w = w - 0.5*2
    ELSEIF OLDWHEEL < WHEEL THEN
      w = w + 0.5*2
    END IF
  END IF[/syntax]

a bit easier mouse rotation handling  :wink:


This is a nice improvement.

I have a FreeBASIC console version that I built before putting the OpenGL front end on it, so I could put a 2D front end on it for older computers. The biggest hassle is menu’s. I would like try out the other gfx modes but some form of menu is needed for the program.

We will see.

Garvan
Logged
VonGodric
Ancient Guru
****
Posts: 674



WWW
« Reply #14 on: May 08, 2005, 03:17:22 AM »

I made a simple gui (it's total crap as it is) but maybe that will help a bit: http://www.hot.ee/fbide/GUI.rar it has buttons, scrollbars and a readonly textarea, but since it is quite object based. adding menus isn't hard. Just follow the way buttons and scrollbars are implemented to the gui. if you like it and wanna use it then contact me if you need help.

Von
Logged

url]http://fbide.sourceforge.net/[/url]
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!