Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
micro(A)v11
#31
OMG
WHILE is a problem ?
maybe i really need to add FOR/NEXT loop ... Sad
Reply
#32
How about if you could demonstrate a simple example of "counting" with recursion with an user "funct"? Like in LISP... (roll eyes)

Please no factorial nor Fibonacci, sick and tired of that!

Can't do too many iterations, or it might overflow the "stack" or something else worse.

Maybe something like this:

Code: (Select All)
var i
i = 0
mycount()

func mycount()
i = i + 1
if i < 20 : mycount() : endif
print 0, i * 30, i
swap
endfn
Reply
#33
There is factorial and there is fibonnaci

Code: (Select All)
' fibonacci series in micro(A)
var a, b, s, i ,n ,x ,y,r
str fbs,noe
fbs="fibonacci sequence in micro(A)"
wcolor 0,0,0 : fcolor 220,180,100
noe = "number of elements ->"
print 380,10,fbs
fcolor 80,140,120
print 380,30,noe
fcolor 100,200,200
a = 1
b = 1
n = 20
y = 50

label start
s = a + b
print 500,y,s
y = y + 20
a = b
b = s
i = i + 1
r=s/3.14
circle y,s,r : circle n,s,r : swap

if i < 23
   goto start
endif
Code: (Select All)
'factorial micro(A)
var value,res
var number ,fact
number = 7
fact = 1
value = 1

print 10, 10, "The factorial of -> " :
print 180,10,number :swap

factorial()

fcolor 230,80,60: print 10,240,"RECURSION OVER!"   
swap

func factorial()
 
  if value < number
       value = value + 1
       fcolor 140,180,220: rect 95,95,80,23: print 100,100,value :swap
       fact = fact * value
      fcolor 240,180,120: rect 95,195,80,23 : print 100,200,fact :swap
       ' recursive call
       factorial()       
  endif

endfn


Attached Files Image(s)
   
Reply
#34
Please no smaller Interpreter with MicroA LOL  Big Grin
b = b + ...
Reply
#35
The game you apparently didn't like was the one my friend failed to translate to micro(A). Rolleyes

It's simply because it needs more LOC to give the illusion of animation. Such as pressing [9] key, the ship moves down the lane and the player sees all nine steps of it. Put a starry background and make it move as part of the illusion.

But it was meant to be a simple game. Not for some slob to steal it without making any modification to it except the "original author" comment at the top.

This was sort of based on another game which was about cars instead. Not really a race. But the "aliens" were drunk drivers determined to crash into the player's car. The player's car could move vertically in that other game but not very far ahead, it was sort of like the ship in Centipede. Also this was more or less like "Demolition Derby", my favorite Tandy Color Computer cartridge. Heart
Reply
#36
(07-29-2023, 07:07 PM)mnrvovrfc Wrote: The game you apparently didn't like was the one my friend failed to translate to micro(A).  Rolleyes

It's simply because it needs more LOC to give the illusion of animation. Such as pressing [9] key, the ship moves down the lane and the player sees all nine steps of it. Put a starry background and make it move as part of the illusion.

But it was meant to be a simple game. Not for some slob to steal it without making any modification to it except the "original author" comment at the top.

This was sort of based on another game which was about cars instead. Not really a race. But the "aliens" were drunk drivers determined to crash into the player's car. The player's car could move vertically in that other game but not very far ahead, it was sort of like the ship in Centipede. Also this was more or less like "Demolition Derby", my favorite Tandy Color Computer cartridge. Heart

If you are talking to me, I didn't like it because it didn't work. The digit keys didn't respond nor the shift keys???

And my code started from scratch trying to figure out what roquedrivel was trying to accomplish. So nobody let alone slobs was stealing noth'n. Big Grin

Check it out, I was just guessing at how it might have worked:
Code: (Select All)
_Title "roquedrivel Game" ' b+ 2023-07-28
DefLng A-Z ' make all variables long
Width 40
debug = 0 ' this is for checking things along the way
rightBoundary = 10
playerX = 5: playerY = 25: player$ = "A"
gateX = Rand(10): gateY = 25 - Rand(13): gate$ = "X" ' not installed yet
Dim As Long badX(1 To 4), badY(1 To 4) ' baddies locates
bad$ = "V"
GoSub ReassignBaddies
'If debug Then Sleep 'check progress
Do
    Cls ' then display current status
    For i = 1 To 25
        Locate i, 11: Print Chr$(179);
    Next
    Locate 12, 15: Print "Score:"; score
    For i = 1 To 4 ' draw baddies then move them unless a collision with player
        If playerX = badX(i) And playerY = badY(i) Then
            player$ = "*": score = score - 1
            Locate playerY, playerX: Print player$
            Sound 600, 4
        Else
            Locate badY(i), badX(i): Print bad$;
        End If
        If Rand(60) < 5 Then badY(i) = badY(i) + 1
        If badY(i) > 25 Then
            restart2:
            r = Rand&(10)
            For j = 1 To 4 ' find a new lane
                If j <> i Then
                    If badX(j) = r Then GoTo restart2 ' find another lane this one is used
                End If
            Next
            badX(i) = r: badY(i) = 1 ' give the bad(i) a new start
        End If
    Next
    Locate playerY, playerX: Print player$; ' wait for player to do something
    If player$ = "*" Then
        playerY = 25: player$ = "A"
        GoSub ReassignBaddies
    ElseIf playerY = 1 Then
        GoSub ReassignBaddies
        score = score + 1
        playerY = 25
    Else
        kh = _KeyHit
        If kh >= 48 And kh <= 57 Then ' digits 1 to 9, 0 = 10
            move = kh - 48
            If move = 0 Then move = 10
            If (playerY - move) < 1 Then Beep: GoTo skip
            For i = 1 To move
                For b = 1 To 4
                    If playerY - i = badY(b) And playerX = badX(b) Then Beep: GoTo skip
                Next
            Next
            playerY = playerY - move
            skip:
        ElseIf kh = 19200 Then ' left arrow
            If playerX - 1 < 1 Then Beep Else playerX = playerX - 1
        ElseIf kh = 19712 Then ' right arrow
            If playerX + 1 > rightBoundary Then Beep Else playerX = playerX + 1
        ElseIf kh = 27 Then
            End
        End If
    End If
    _Limit 30 ' loop 30 times a sec   2 secs = 60 frames
Loop
End

ReassignBaddies:
badX(1) = Rand&(10): badY(1) = 1
For i = 2 To 4 ' assign a lane
    restart:
    r = Rand&(10)
    For j = 1 To i - 1
        If badX(j) = r Then GoTo restart ' find another lane this one is used
    Next
    badX(i) = r: badY(i) = 1 ' give the baddies a place
    If debug Then Print i; badX(i); badY(i) ' check progress
Next
Return

Function Rand& (maxnum As Long) ' 1 to maxnum inclusive
    Rand& = Int(Rnd * maxnum + 1)
End Function

After I posted, I learn the ship was supposed to stay at bottom of screen, yikes!
b = b + ...
Reply
#37
I just need explanation why _keydown(37) not work in qb64
it should work ..not with some crazy constant which don't have nothing
with virtual key codes ?
Reply
#38
or maybe WMKEYDOWN is that constant Huh
Reply
#39
_Keydown(37) is for Shift + % in QB64pe

Here is code I use to tell me Inkey$ or _Keyhit # which is usually the same for _Keydown
Code: (Select All)
While 1 'find code for keypress
k$ = InKey$
hk& = _KeyHit
If Len(k$) Then
Select Case Len(k$)
Case 1: Print "1 char keypress = "; Asc(k$); " keyhit = "; hk&
Case 2: Print "2 char keypress = "; Asc(Right$(k$, 1)); " keyhit = "; hk&
End Select
End If
_Display
_Limit 60
Wend
Print "Goodbye."

'findings
'<esc> pressed twice exits this screen! number printed after 2nd press of any

'Alt + letter -> 2 char keypress numbers seem to jump all around they are QWERTY order?

'Ctrl + letter -> 1 char A = 1, B = 2...
'Ctrl + m is same as <enter>

'arrows
'up 72, dowm 80, left 75, right 77


' _keyhit constants
' up 18432
' down 20480
' left 19200
' right 19712
' pg up 18688
' pgdwn 20736
Const KEY_ARROW_LEFT = 19200
Const KEY_ARROW_UP = 18432
Const KEY_ARROW_RIGHT = 19712
Const KEY_ARROW_DOWN = 20480
Const KEY_PAGE_UP = 18688
Const KEY_PAGE_DOWN = 20736
b = b + ...
Reply
#40
Admittedly, the game was bad. Needed more work.

The thing was either to press a key to type a numeral, or use one of the [SHIFT] keys to nudge the ship sideways. Not to try to type "%" or other such character which requires [SHIFT].

The game should have used _KEYDOWN for all keystroke handling. "roquedrivel" isn't patient for stuff like that but otherwise would have had to program for the left and right arrow keys.

Remember that on this topic we're supposed to contribute micro(A) programs only. "roquedrivel" decided to offer one "they" were working on in QB64 which became too much to change so it runs on micro(A), but because micro(A) has nothing like SCREEN 0.

Many games for the ancient Atari, Tandy, Timex etc. computers were austere like this, but people went crazy for it at least during the late 1970's while BASIC was a hot topic. Then there was the need to use assembly language to make it faster, to use graphics mode, to employ sprites, to make it sound off... make it more complicated so it could be sold for money instead of remaining printed in a magazine.

On this forum I can't find a good game that JDJ did some months ago, which was a car race. It was different from mine, but I can't find my topic neither. That does real vertical scrolling and the player has to remain within the lane, besides watching out for obstacles.
Reply




Users browsing this thread: 3 Guest(s)