26 February 2015, 22:12 | #21 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Here is my base skeleton to get you started.
Please note the order of appearance of Functions/Statements. As i said before, you can only call those after they are defined (in source, not in real time appearance). Code:
._about
.
.init
; no doublebuffer yet !
;
#Width =$80000023
#Height =$80000024
#Dpth =$80000025
#Typ =$8000002D
#DisplayID =$80000032
#Overscan =$80000034
#AutoScroll =$80000039
#LikeWorkbench=$80000047
;NOTE:We use an AGA (classic chipset) screen mode Workbench!!!
ScreenTags1,"tetris test",#LikeWorkbench,True,#Width,800,#Height,600,#Dpth,8,#AutoScroll,True,0,0
Window 1,0,0,800,600,$1900,"",2,1 ;print to window with Text{}
ScreensBitMap1,1 ;gfx output (chg to window later)
BitMapOutput1 ;Print to bmap
._macros
Macro myshared
Macro Origin
.funcs
Statement Text {x,y,txt$,col}
Statement DrawBlk {col, x, y, fade}
Statement DrawBoardBlocks{}
Statement DrawBoard{}
Statement DrawGhostPiece{}
Statement DrawCurrentPiece{}
Statement DrawNextPiece{}
Statement DrawInfo{}
Statement CalcGhostPosition{}
Statement ResetPiece{}
Function DropPiece{}
Statement CheckForLines{}
Function PlacePiece{}
Statement LineClearer{}
Statement MoveLeft{}
Statement MoveRight{}
Statement RotatePiece{rotateLeft}
Statement DrawPauseMessage {}
Statement EndGame{}
Statement PrintGameOver{}
Statement StartNewGame{}
Statement ProcessInputs{}
.main
Repeat
;
Until exit;Esc key
.mloop
.
End
._colsdat
._piecedat
.eof
Note also (if you don't saw it before): The original program is updating the screen all the time, you certainly don't want that, it is too slow anyway. Last edited by Cylon; 26 February 2015 at 22:55. Reason: act. adds |
26 February 2015, 22:47 | #22 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
So far:
|
27 February 2015, 08:33 | #23 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,583
|
feel like am plying chess with the devil; macros, labels, physical addresses, how a n00b know that, and where they explain it? The most understandable tutorial i found online is the one from labritcho, the AF and CU print stuff follow but not at the same level; however this feels years ahead...
so right now have TED getting stuck at this line with a syntax error: Code:
DrawBlk{r, g, b, xx+CurPieceX*25 + xiter*25, yy+GhostPieceY*25 + yiter*25, 1} Code:
Function DrawBlk{r, g, b, x, y, faden} !sharedstuff ; Color r, g, b ; Rect x, y, 24, 24 ; Color r * fade#, g * fade#, b * faden ; Rect x + 2, y + 2, 20, 20, 0 ; Line x, y, x+2, y+2 ; Line x, y+23, x+23, y+23 ; Line x+1, y+22, x+22, y+22 ; Line x+22, y+1, x+22, y+22 ; Line x+23, y, x+23, y+23 End Function Last edited by saimon69; 27 February 2015 at 08:45. |
28 February 2015, 01:12 | #24 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
i have done some changes:
ProcessInput{} seems to work, Timing is odd, but works(??), GhostPieces got an own color (we dont use fade and rgb drawing), Esc & Quit works (some)times. Removed CLS, added EraseBoard{} to replace it. Flicker is present, as expected. I will post parts of src (or all of it?) later, on request. Could be a tutorial or a guided first-steps-to-blitz. Last edited by Cylon; 28 February 2015 at 02:41. |
28 February 2015, 01:28 | #25 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Quote:
it should look (in my adaption) like this: Code:
._DrawBlk Statement DrawBlk {col, x, y, fade} !myshared ;Color r, g, b ;Rect x, y, 24, 24 Boxf x,y,x+24,y+24,col ;Color r * fade, g * fade, b * fade ;Rect x + 2, y + 2, 20, 20, 0 ;we donot support shaded faces yet ;Line x, y, x+2, y+2 ,col ;Line x, y+23, x+23, y+23 ,col ;Line x+1, y+22, x+22, y+22 ,col ;Line x+22, y+1, x+22, y+22 ,col ;Line x+23, y, x+23, y+23 ,col End Statement A statement is a command: Code:
PRINT A A function is a request: Code:
whatis = Len ("example") |
|
28 February 2015, 01:59 | #26 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
As i mentioned before, we cannot (easily) use 24 bit rgb gfx within Blitzbasic2 while keeping the look&feel of BASIC.
So thats the reason why i try to avoid to much specific code and keep the src understandable. I suggested to chg the Piece/Color behavior to use indexed color entries, so we don't use calls like this Code:
Statement DrawBoardBlocks{} ;draw blocks Origin OrigBoardX, OrigBoardY For yiter = 0 To 22 For xiter = 0 To 9 If Board(xiter, yiter) <> 0 r = BlockColor(Board(xiter, yiter), 0) g = BlockColor(Board(xiter, yiter), 1) b = BlockColor(Board(xiter, yiter), 2) DrawBlk{r, g, b, xiter*25, yiter*25, .25} EndIf Next Next End Statement Code:
Statement DrawBoardBlocks{} !myshared ;draw blocks !Origin {OrigBoardX, OrigBoardY} ;xx,yy For yiter = 0 To 22 For xiter = 0 To 9 If Board(xiter, yiter) <> 0 col=Board(xiter, yiter) DrawBlk{col,xx+ (xiter*25),yy+ (yiter*25), .25} EndIf Next Next End Statement Instead we do a Piece>Col=Piece>DrawBoxes. The colors are set in the Startup; we use a Screen with max 256 cols, but we don't need that much colors (yet ) , so 16 or 32 colors are enough for now. Ok. so, when we want to use indexed colors (and not 24bit truecolor), we have to define those colors somehow. That's how we do it: Code:
;now let`s reshape the color behaviour ;we are NOT using RGB values To draw, we don`t Use this 24bit system. ;instead, we draw with index colors. ;NOTE: the first 7 constants are the very first in the formerly known BlockColor() array. this is for easy nderstanding only. #cyellow =1 ; 255, 255, 0 ;yellow #cturquoise=2 ; 0, 128, 255 ;turquoise #cblue =3 ; 0, 0, 255 ;blue #corange =4 ; 255, 128, 0 ;orange #cred =5 ; 255, 0, 0 ;red #cgreen =6 ; 0, 255, 0 ;green #cpurple =7 ; 128, 0, 255 ;purple ;more cols added #cwhite =8 ; 255, 255, 255 ;white #cgrey50 =9 ; 128, 128, 128 ;grey 50% #cblack =10 ; 0, 0, 0 ;black #cgrey25 =11 ; 64, 64, 64 ;grey 25% ghostpiece color ._DataRead ;read in block color data ;Please DIM the BlockColor() to maxcols! Restore _colsdat Read maxcols For iter = 1 To maxcols Read BlockColor(iter, 0) Read BlockColor(iter, 1) Read BlockColor(iter, 2) AGAPalRGB 1,iter, BlockColor(iter, 0),BlockColor(iter, 1),BlockColor(iter, 2) Next Use Screen1 ShowPalette 1 ._colsdat Data 11 ;maxcols Data 255, 255, 0;yellow Data 0, 128, 255;turquoise Data 0, 0, 255 ;blue Data 255, 128, 0;orange Data 255, 0, 0 ;red Data 0, 255, 0 ;green Data 128, 0, 255;purple ;more cols added Data 255,255,255;white Data 128,128,128;grey 50% Data 0,0,0 ;black Data 64,64,64 ;grey 25% for ghostpiece Now whenever we find a Color rr,gg,bb call in the original source, we try to replace it: Code:
Statement PrintGameOver{} !myshared !Origin {OrigMessAreaX, OrigMessAreaY} ;> xx, yy ;Color 255, 0, 0 ;this is blue (is it?) Text {xx+ 150,yy+ 50, "Game Over",#cred}; True, True ;Color 255, 255, 0 ;this is orange Text {xx+ 150,yy+ 100, "Press 'N' to",#corange} Text {xx+ 150,yy+ 120, "start a new game.",#corange} Text {xx+ 150,yy+ 230, "Press ESC to quit.",#corange} End Statement All #constants are available within the entire source without taking care of local/global/shared etc.; so if you want to use a colorpen try to use e.g. #cwhite for use with Boxf or whatever. Last edited by Cylon; 28 February 2015 at 02:24. |
28 February 2015, 02:11 | #27 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
The (new) Text{} statement used to replaced the given Text .... is as follows:
Code:
Statement Text {x,y,txt$,col} If Len(txt$)>0 WindowOutput1 WLocate x,y WColour col,0 Print txt$ EndIf End Statement |
28 February 2015, 03:08 | #28 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Quote:
Those things. |
|
03 March 2015, 01:39 | #29 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,583
|
hope to find time tonight to work more
|
05 March 2015, 20:29 | #30 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Try to understand, what it does and why it fails. When the debugger stops (once you've got it running) then hit 'e' to enter a variable you need to know its value, hit 's' to step run forward. That way you can follow a variable change during program flow.
|
05 March 2015, 21:14 | #31 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,583
|
Well since still does not compile i see there is a good amount of stuff to do there...
|
06 March 2015, 21:05 | #32 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Keep the pace up...
Here's my raw version, AA workbench screen (to clone) required. it is very hard to play, bcause of the timing and flickering, but it works.
start with "n", cursor keys left right to move piece, "x" + "c" to rotate, ESC for end. I hope it is encouraging for you. p.s.:i've got fade/shade support for drawblk here; don't use it without surrounding framework! Code:
._DrawBlk Statement DrawBlk {col, x, y, fade} !myshared Boxf x,y,x+24,y+24,col If fade>0 AND col<8 col+#cfadeofs Boxf x+2,y+2,x+22,y+22,col Line x, y, x+2, y+2 ,col Line x, y+23, x+23, y+23 ,col Line x+1, y+22, x+22, y+22 ,col Line x+22, y+1, x+22, y+22 ,col Line x+23, y, x+23, y+23 ,col EndIf End Statement Code:
._colsdat Data 18 ;maxcols Data 255, 255, 0;yellow Data 0, 128, 255;turquoise Data 0, 0, 255 ;blue Data 255, 128, 0;orange Data 255, 0, 0 ;red Data 0, 255, 0 ;green Data 128, 0, 255;purple ;more cols added Data 255,255,255;white Data 128,128,128;grey 50% Data 0,0,0 ;black Data 64,64,64 ;grey 25% for ghostpiece ;11+ fade colors Data 64, 64, 0;yellow 25% Data 0, 32, 64;turquoise 25% Data 0, 0, 64 ;blue 25% Data 64, 32, 0;orange 25% Data 64, 0, 0 ;red 25% Data 0, 64, 0 ;green 25% Data 32, 0, 64;purple 25% Code:
._Dims ;set up arrays Dim Board (9, 22) Dim BlockColor (99, 2) ;99 cols is enough?!? we use them as color index Dim Piece (28, 3, 3) Dim LineToErase (4) ;now let`s reshape the color behaviour ;we are NOT using RGB values To draw, we don`t Use this 24bit system. ;instead, we draw with index colors. #cyellow =1 ; 255, 255, 0 ;yellow #cturquoise=2 ; 0, 128, 255 ;turquoise #cblue =3 ; 0, 0, 255 ;blue #corange =4 ; 255, 128, 0 ;orange #cred =5 ; 255, 0, 0 ;red #cgreen =6 ; 0, 255, 0 ;green #cpurple =7 ; 128, 0, 255 ;purple ;more cols added #cwhite =8 ; 255, 255, 255 ;white #cgrey50 =9 ; 128, 128, 128 ;grey 50% #cblack =10 ; 0, 0, 0 ;black #cgrey25 =11 ; 64, 64, 64 ;grey 25% ghostpiece color #cfadeofs =11 ;this is the offset for fade colors! ._DataRead ;read in block color data Restore _colsdat Read maxcols For iter = 1 To maxcols Read BlockColor(iter, 0) Read BlockColor(iter, 1) Read BlockColor(iter, 2) AGAPalRGB 1,iter, BlockColor(iter, 0),BlockColor(iter, 1),BlockColor(iter, 2) Next Use Screen1 ShowPalette 1 Last edited by Cylon; 07 March 2015 at 02:54. Reason: pic added |
06 March 2015, 21:49 | #33 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Quote:
When your Statement is of Statement {var1,var2,var3,var4} then you have to call it also with 4 values to work with. Syntax errors are sometimes hard to find because it can be a very tiny simple thing, like using a ',' instead of a ':' . |
|
13 March 2015, 07:54 | #34 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,583
|
going further on writing: this line
Code:
ScreenTags1,"tetris test",#LikeWorkbench,True,#Width,800,#Height,600,#Dpth,8,#AutoScroll,True,0,0 Did i mention i am using blitz v2.10, if that is important? |
14 March 2015, 00:44 | #35 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Quote:
The Constants are case sensitive and should look like this: Code:
#Width =$80000023 #Height =$80000024 #Dpth =$80000025 #Typ =$8000002D #DisplayID =$80000032 #Overscan =$80000034 #AutoScroll =$80000039 #LikeWorkbench=$80000047 |
|
16 March 2015, 18:17 | #36 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,583
|
Is still early since this thing not even compile yet but would adapt it to ruin in a 320x256 window using graphic tiles. how complicated will be to adapt everything?
|
17 March 2015, 21:56 | #37 | |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 473
|
Quote:
If it does not compile, try to start over new only with the few lines to create the screen with a window and a MouseWait:end. Don't do anything else until you have a screen you can rely on. |
|
18 March 2015, 02:00 | #38 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,583
|
have two IF NOT statementname{} THEN condition that the compiler don't like in the main loop [no, using If NOT (return from)stetementname{} seems not to work] and also a problem with the milliseconds() constant that is used for some calculations; i disabled it so far but wonder if that can give me problems.
|
18 March 2015, 07:47 | #39 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,583
|
update: i reach compilation! I commented the if not that was giving me trouble and now am in an empty screen.
Now am going to add the colors and other stuff that were not included first. |
18 March 2015, 23:08 | #40 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,647
|
Moved this thread to the Coders.Languages forum. Please post in the designated forums in future. Carry on
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tutorials for Amiga Blitz Basic 2? | Kenan | support.Other | 2 | 19 July 2013 23:27 |
amiga and old blitz basic prog - please help | brian hills | support.Other | 7 | 05 October 2009 01:56 |
Wanting to learn Blitz Basic on real Amiga | Adropac2 | request.Other | 20 | 20 August 2008 07:30 |
blitz basic | petza | request.Apps | 11 | 08 April 2007 01:49 |
Blitz Basic 2 | LaundroMat | Retrogaming General Discussion | 5 | 24 July 2001 08:10 |
|
|