English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 19 March 2015, 09:21   #41
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
Well i see colors, i see some text, i DONT see the blocks yet... going on...
saimon69 is offline  
Old 20 March 2015, 06:36   #42
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
Now first i found was hawing two screens (my fault)then the grid appear but is kinda skewed so i really need to update stuff

Click image for larger version

Name:	blitztetris1.jpg
Views:	242
Size:	72.0 KB
ID:	43656
saimon69 is offline  
Old 20 March 2015, 07:08   #43
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
update: actual situation with no blocks and a error concerning Piece() as Array subscript out of range
Click image for larger version

Name:	blitztetris2.jpg
Views:	479
Size:	52.5 KB
ID:	43658
Click image for larger version

Name:	blitztetris21.jpg
Views:	452
Size:	168.1 KB
ID:	43657
saimon69 is offline  
Old 22 March 2015, 00:47   #44
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by saimon69 View Post
update: actual situation with no blocks and a error concerning Piece() as Array subscript out of range
Attachment 43658
Attachment 43657
Let me guess: if you 'eval' the pieceToCheck variable, it turns out to be negative, doesn't it?

Thats a tricky one for a beginner, not easy to solve.
Let's have a look at it:
Code:
  pieceToCheck = CurrentPiece + (((CurPieceRot + 1) * (CurPieceRot < 3)) * 7)
The interesting part is this:
Code:
(CurPieceRot < 3)
What does this mean?
Well, it gives you a boolean answer for: Is CurPieceRot less than 3 (or is it not). The answer is given as TRUE or FALSE, while TRUE (in Blitzbasic Amiga) means -1 (!), FALSE means 0.
If the result is indeed True, it becomes -1 multiplied with 7 and some, ending up as -7, causing sometimes the array limits being underrun.
Solution:
Make the result absolute!
The standard BASIC cmd (function) for this is ABS(), or a little bit quicker in Blitz, QAbs().
Code:
  pieceToCheck = CurrentPiece + (((CurPieceRot + 1) * QAbs(CurPieceRot < 3)) * 7)
This happens like two or three times in the source, iirc.

btw., milliseconds() can be replaced with Ticks. Ticks is from elmorehw.lib.
If this is not shown in your Blitzted as a highlighted command the solution is probably not beginnerfriendly anymore i'm afraid.

Last edited by Cylon; 22 March 2015 at 01:47.
Cylon is offline  
Old 24 March 2015, 08:58   #45
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
hmm have no PieceToCheck variable - er correction i found it but still have the error

Last edited by saimon69; 25 March 2015 at 07:17.
saimon69 is offline  
Old 28 March 2015, 00:19   #46
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
This is the RotatePiece{} function it should look like:

Code:
Statement RotatePiece{rotateLeft}
!myshared
  ;Local pieceToCheck
  If rotateLeft
    pieceToCheck = CurrentPiece + (((CurPieceRot - 1) + 4 * QAbs(CurPieceRot < 1)) * 7)
  Else
    pieceToCheck = CurrentPiece + (((CurPieceRot + 1) * QAbs(CurPieceRot < 3)) * 7)
  EndIf
  For yiter = 0 To 3
    For xiter = 0 To 3
      If Piece(pieceToCheck, xiter, yiter) <> 0
        If ((CurPieceX+xiter) < 0) OR ((CurPieceX+xiter) > 9) OR ((CurPieceY+yiter) > 22) Then Statement Return
        If Board(CurPieceX+xiter, CurPieceY+yiter) <> 0 Then Statement Return
      EndIf
    Next
  Next
  If rotateLeft
    CurPieceRot = (CurPieceRot - 1) + 4 * QAbs(CurPieceRot < 1)
  Else
    CurPieceRot = (CurPieceRot + 1) * QAbs(CurPieceRot < 3)
  EndIf
  CalcGhostPosition{}
End Statement
Cylon is offline  
Old 28 March 2015, 01:13   #47
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by Cylon View Post
You have to understand the difference between a function and a statement:

A statement is a command:
Code:
PRINT A
.
A function is a request:
Code:
whatis = Len ("example")
.
Well, you might noticed before: I often use Function when i mean Function OR Statement. So here is a clearification:

A Statement is a function without a return value.
Code:
Statement foo{}
  ;bla
End Statement
A Function is a function with a mandatory(!) return value.
Code:
Function foo{}
   ;bla
   Function Return retvalue
End Function
Either of those functions can be terminated (leaved) earlier:
Code:
Statement foo{}
   ;bla
   if a>x then Statement Return
   ;more bla
End Statement
; for the Function{} you must return something (a 0 will do)
Code:
Function foo{}
   ;bla
   if a>x then Function Return retvalue
End Function
I hope this helps a little. Blitz is BASIC with a little bit more, that only the manual can explain.
Cylon is offline  
Old 28 March 2015, 19:42   #48
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
My source is starting to get messy and i am having proble m understand why have a huge flickering no pices on board and everything stops when the (black) piece reach the bottom... source included (no i did not read yours for a stubborn pride to try to figure out on myself)
Attached Files
File Type: txt tetris_am292.bb2_asc.txt (18.0 KB, 185 views)
saimon69 is offline  
Old 28 March 2015, 22:50   #49
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by saimon69 View Post
My source is starting to get messy and i am having proble m understand why have a huge flickering no pices on board and everything stops when the (black) piece reach the bottom...
Code:
Statement DrawNextPiece{}
!sharedstuff
 !Origin {OrigNextPieceX, OrigNextPieceY}
 ; r = BlockColor(NextPiece, 0)
 ; g = BlockColor(NextPiece, 1)
 ; b = BlockColor(NextPiece, 2)
  For yiter = 0 To 3
    For xiter = 0 To 3
      If Piece(NextPiece, xiter, yiter)
        DrawBlk{col, xx+xiter*25, yy+yiter*25, .25}
      EndIf
    Next
  Next
End Statement
You forgot to define col, so it will be 0 (black).
If you remember, we defined the basic piece colors matching their piece numbers? So, col=NextPiece, or,
Code:
DrawBlk{NextPiece, xx+xiter*25, yy+yiter*25, .25}
Code:
Statement CheckForLines{}
...
 ...
 ...
  BlockToErase = 5
  Points = (NumLines + (NumLines - 1)) + (1 * (NumLines = 4))
...
  If Lines < 1
    DropSpeed = DropSpeed - 50 + (50 * (DropSpeed < 50))
    ...
  EndIf
End Statement
Here you can find the same situation we talked about earlier:
These evaluations deliver a possible negative result, so you must add a QAbs in front of them.
Code:
Statement DropPiece{}
...
        If ((CurPieceY+yiter)+1) > 22 Then Statement Return ;False
        If Board(CurPieceX+xiter, CurPieceY+yiter+1) <> 0 Then Statement Return ;False
 ...
End Statement
DropPiece{} is one of the few real Functions, meaning they return something, in this case True or False, so
Code:
Function DropPiece{}
        If ((CurPieceY+yiter)+1) > 22 Then Function Return False
        If Board(CurPieceX+xiter, CurPieceY+yiter+1) <> 0 Then Function Return False
...
End Function
Same for Function PlacePiece{}.
Code:
Statement EndGame{}
  EndOfGame = True
  GamePaused = False
End Statement
You forgot the !sharedstuff Macro call. The values set in this statement are lost, because without the shared (global) assignment they are only valid inside the very procedure.


Well, there is more (e.g. the Repeat-Forever loop in FindGhostPiece{} and the ProcessInputs{} need attention). Maybe you should actually read something i wrote despite your pride. It will help, believe me.
Cylon is offline  
Old 30 March 2015, 09:23   #50
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
@cylon

actually i did read all you wrote, thought the .lha file included a source code, and did not opened that.

so now am here with a couple of IF NOT(return from)DropPiece{} that i have no clue on how to translate, plus the Repeat...forever that have no clue how to modify.

The game seems to run, i changed the the references from col to CurPiece and NextPiece but the piece still dont want to appear.
saimon69 is offline  
Old 01 April 2015, 22:54   #51
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by saimon69 View Post
@cylon

actually i did read all you wrote, thought the .lha file included a source code, and did not opened that.
There is no src included in this file, because nobody requested it.
It is just the stage i left it in running condition (executable) at that time.
Quote:
so now am here with a couple of IF NOT(return from)DropPiece{} that i have no clue on how to translate, plus the Repeat...forever that have no clue how to modify.
Hm, i thought it would be obvious, but:
IF NOT(return from)DropPiece{}
is: (think this) to understand what Function{} means; it returns something.
Quote:
The game seems to run, i changed the the references from col to CurPiece and NextPiece but the piece still dont want to appear.
This is because you're stuck in the "Forever" loop.
I did not even try to find the cause of it; did you hit CTRL+ALT+C to break into the debugger? Trace the variables (hit "e" then enter a variable name you can see in src window of debugger).
I've changed the condition of this loop from forever to something else (btm of array iirc), i'll tell you later.
Cylon is offline  
Old 02 April 2015, 01:31   #52
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
Using the Trace command made me receive a Recoverable Alert, is something i have to deal with all the time?
saimon69 is offline  
Old 04 April 2015, 00:51   #53
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by saimon69 View Post
Using the Trace command made me receive a Recoverable Alert, is something i have to deal with all the time?
Don't use the Trace command. (yet).

Use the Eval command ("e" from keyboard).

If you get an alert, something went awfully wrong, so please stay alert.
Cylon is offline  
Old 04 April 2015, 02:00   #54
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by Cylon View Post
I've written one couple of years ago, but the src is not public. What you need is: Look how tetris works and figure out how to do this by yourself. It is fairly simple.
See:

You are not in the mood to really pull it off (yet), i believe.
Attached Thumbnails
Click image for larger version

Name:	mytetris_002.png
Views:	279
Size:	16.9 KB
ID:	43865  

Last edited by Cylon; 06 April 2015 at 14:55. Reason: reason?
Cylon is offline  
Old 04 April 2015, 07:55   #55
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
The most complicated program i wrote was involving four ships following the player on ZX spectrum so tetris is a bit different from what i did so far. Include that i can only work one or two hour per night, per one or two nights per week. Am getting hold of the several parts of the language however i feel still have a long way to go, indeed.
saimon69 is offline  
Old 05 April 2015, 19:48   #56
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
About the Return From - those are things that in javascript or PHP i do all time,like:
Code:
var me = function(){
return you;
}

if(!me){him}
just that the way blitz does sounds a bit arcane to me, anjd i did never used fuctions when was doing BASIC programming, just a bunch of gotos and gosubs...
saimon69 is offline  
Old 09 April 2015, 05:55   #57
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
Changed IF NOT (return from) funcName in IF NOT funcName; now going to try to fix the repeat forever...

Every time i press E i get the recoverable alert so yes there IS something wrong there...

ok going on i found that was not drawing the block properly, so now have something in screen but it does not move (due to me commenting CalcGhostPiece maybe but still have no clue on how to set until)


Click image for larger version

Name:	blitztetris040915.jpg
Views:	429
Size:	47.8 KB
ID:	43933

Last edited by saimon69; 09 April 2015 at 09:29. Reason: addition
saimon69 is offline  
Old 11 April 2015, 00:36   #58
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by saimon69 View Post
Every time i press E i get the recoverable alert so yes there IS something wrong there...
Attachment 43933
Are you pressing E during program execution or after pressing CTRL+ALT+C (means entering the debugger)?
Cylon is offline  
Old 11 April 2015, 03:16   #59
saimon69
J.M.D - Bedroom Musician
 
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,516
tried both ways same result
saimon69 is offline  
Old 12 April 2015, 01:04   #60
Cylon
Registered User
 
Join Date: Oct 2014
Location: Europe
Posts: 470
Quote:
Originally Posted by saimon69 View Post
tried both ways same result
Strange!
Donot press E again.

When you enter the debugger, click the "EVAL" button instead.
Cylon is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:48.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12402 seconds with 14 queries