Post by Nicky Peter Hollyoake on Mar 28, 2008 21:43:25 GMT -5
Ok, the notes are at the top of the program whats done and not done (well theres notes all over the code).
Someone give me some help on moving pieces? I can't figure out a way, maybe because its 2:43am in the mornin', took me about 30-60 minutes to get this far.
NOTES:
- Colors will be improved by textures.
- Hopefully movement will start going on (gonna get some sleep first, because i'll never be able to think. )
Thats all for now,
- Nicky
P. S. I know I should of posted it when its atleast playable, sorry.
EDIT:
I did post for help and to see what people think so far. Does people prefer mouse control, or keyboard control? Please tell me.
'Notes:
'Colors need to be improved by textures (this will be done).
'Movement need to be made
Declare Function CreateSquare(List, X#, Y#) 'X, Y = Size [not pos!]
Declare Function CreateQuad(List, X#, Y#, Z#) 'X, Y, Z = Size [not pos!]
'Chess piece varibles, strucs, etc
Data "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Castle", "Horse", "Bishop", "King", "Queen", "Bishop", "Horse", "Castle" 'Player 1
Data "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Pawn", "Castle", "Horse", "Bishop", "Queen", "King", "Bishop", "Horse", "Castle" 'Player 2
Struc sPiece
Dim Pos#(1)
Dim Name$
Dim OnScreen
EndStruc
Struc sPlayer
Dim sPiece Piece(15)
EndStruc
Dim sPlayer Player(1)
'Call varibles
Dim Board
Dim Piece
Dim Cursor
'Cursor varible
Dim Cursor#(1)
'local varibles
Dim X, Z
Dim j, i
Board = CreateSquare(1, 1, 1)
Piece = CreateQuad(2, .5, 1, .5)
Cursor = CreateQuad(3, .1, 7, .1)
'Players name & pos
For j = 0 To 1
For i = 0 To 15
Read Player(j).Piece(i).Name$
if j = 0 Then
if i < 8 Then
Player(j).Piece(i).Pos# = Vec2(i, 7)
Else
Player(j).Piece(i).Pos# = Vec2(i-8, 6)
Endif
Else
if i < 8 Then
Player(j).Piece(i).Pos# = Vec2(i, 0)
Else
Player(j).Piece(i).Pos# = Vec2(i-8, 1)
Endif
Endif
Next
Next
'Main loop
While TRUE: GLClear(GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT)
GLLoadidentity()
GLTransLateF(- 4, - 5, - 20) 'Worlds position
GLRotateF(0, 0, 1, 0) 'Worlds X rotation [note: will be removed if not used]
GLRotateF(10, 1, 0, 0) 'Worlds Y rotation
'Board
For Z = 0 To 7
For X = 0 To 7
GLPushMatrix()
GLTransLateF(X, 0, Z)
GLRotateF(90, 1, 0, 0) 'Turn it 90 degrees so its laying flat!
'Color
if (X+Z) % 2 = 0 Then
GLColor3F(.5, .5, .5)
Else GLColor3F(1, 1, 1)
Endif
GLCallList(Board)
GLPopMatrix()
Next
Next
'Pieces
For j = 0 To 1
For i = 0 To 15
GLPushMatrix()
GLTransLateF(Player(j).Piece(i).Pos#(0) + .25, 0, Player(j).Piece(i).Pos#(1) + .25)
if j = 0 Then
GLColor3F(1, 0, 1)
Else GLColor3F(0, 0, 1)
Endif
GLCallList(Piece)
GLPopMatrix()
Next
Next
'Move cursor by mouse
Cursor# = Vec2(INT(Mouse_X() * 8), INT(Mouse_Y() * 8))
'Move cursor by keyboard input [note: I don't think I can make movement by mouse & keyboard]
if ScanKeyDown (VK_RIGHT) Then
Cursor#(0) = (Cursor#(0) + 1)
Elseif ScanKeyDown (VK_LEFT) Then
Cursor#(0) = (Cursor#(0) - 1)
Endif
if ScanKeyDown (VK_UP) Then
Cursor#(1) = (Cursor#(1) - 1)
Elseif ScanKeyDown (VK_DOWN) Then
Cursor#(1) = (Cursor#(1) + 1)
Endif
'Cursor [note: this one doesn't need GLPushMatrix()/GLPopMatrix() as 'GLLoadidentity' will be called in the next loop]
GLTransLateF(Cursor#(0)+.49, 0, Cursor#(1)+.49)
GLColor3F(1, 0, 0)
GLCallList(Cursor)
Swapbuffers()
Wend
'Functions
Function CreateSquare(List, X#, Y#)
Dim Square: Square = GLGenLists(List)
GLNewList(Square, GL_COMPILE)
GLScaleF(X#, Y#, 0)
GLBegin (GL_QUADS)
GLVertex2F(0, 1)
GLVertex2F(1, 1)
GLVertex2F(1, 0)
GLVertex2F(0, 0)
GLEnd()
GLEndList()
Return Square
EndFunction
Function CreateQuad(List, X#, Y#, Z#)
Dim Quad: Quad = GLGenLists(List)
Dim Square: Square = CreateSquare(20, 1, 1)
GLNewList(Quad, GL_COMPILE)
GLScaleF(X#, Y#, Z#) 'Quad size!
'Back
GLPushMatrix()
GLTransLateF(0, 0, 0)
GLCallList(Square)
GLPopMatrix()
'Front
GLPushMatrix()
GLTransLateF(0, 0, 1)
GLCallList(Square)
GLPopMatrix()
'Left side
GLPushMatrix()
GLTransLateF(0, 0, 1)
GLRotateF(90, 0, 1, 0)
GLCallList(Square)
GLPopMatrix()
'Right side
GLPushMatrix()
GLTransLateF(1, 0, 1)
GLRotateF(90, 0, 1, 0)
GLCallList(Square)
GLPopMatrix()
'Bottom side
GLPushMatrix()
GLTransLateF(0, 0, 0)
GLRotateF(90, 1, 0, 0)
GLCallList(Square)
GLPopMatrix()
'Up side
GLPushMatrix()
GLTransLateF(0, 1, 0)
GLRotateF(90, 1, 0, 0)
GLCallList(Square)
GLPopMatrix()
GLEndList()
Return Quad
EndFunction
Someone give me some help on moving pieces? I can't figure out a way, maybe because its 2:43am in the mornin', took me about 30-60 minutes to get this far.
NOTES:
- Colors will be improved by textures.
- Hopefully movement will start going on (gonna get some sleep first, because i'll never be able to think. )
Thats all for now,
- Nicky
P. S. I know I should of posted it when its atleast playable, sorry.
EDIT:
I did post for help and to see what people think so far. Does people prefer mouse control, or keyboard control? Please tell me.