Jump to content
IGNORED

Writing My First Lines of Code in Batari Basic


Recommended Posts

Posted (edited)

Just installed Batari Basic last night.  

 

This is what I have so far.  Control a square with the joystick.  ;-)

 

Spoiler

__INTRO x = 50 : y = 50
    COLUPF = 90
    scorecolor = 10
    player0:
 %00000000
 %00000000
 %00111100
 %00111100
 %00111100
 %00111100
 %00000000
 %00000000
end
    
__MAIN COLUP0 = 120 : player0x = x : player0y = y 

    drawscreen
    if joy0up then y = y - 1: if y=0 then y=100
    if joy0down then y = y + 1: if y=100 then y=0
    if joy0left then x = x - 1: if x=0 then x=150
    if joy0right then x = x + 1: if x=150 then x=0
    goto __MAIN

 

Removed the line numbers thanks to a tip from @Random Terrain.  

 

0003 MyGame.txt.bin

 

Isn't it beautiful!  😁

Edited by Living Room Arcade
  • Like 8
Link to comment
Share on other sites

It's so inconsequential in the grand scheme of things but yet somehow personally infinitely exciting.  I remember my first bB program working like it was last week... which it actually was!  :)    I'm right there with you!   Mine was a smiley face sprite, lol.

  • Like 2
Link to comment
Share on other sites

4 hours ago, LatchKeyKid said:

It's so inconsequential in the grand scheme of things but yet somehow personally infinitely exciting.  I remember my first bB program working like it was last week... which it actually was!  :)    I'm right there with you!   Mine was a smiley face sprite, lol.

Source code?  

Link to comment
Share on other sites

16 hours ago, LatchKeyKid said:

It's so inconsequential in the grand scheme of things but yet somehow personally infinitely exciting.  I remember my first bB program working like it was last week... which it actually was!  :)    I'm right there with you!   Mine was a smiley face sprite, lol.

Thanks for your kind support, @LatchKeyKid!  

Link to comment
Share on other sites

Posted (edited)

Version 0004 - Pressing the fire button makes your square go faster.  

 

New keyword: joy0fire 

 

Spoiler

__INTRO x = 50 : y = 50
    COLUPF = 90  
    scorecolor = 10
    player0:
 %00000000
 %00000000
 %00111100
 %00111100
 %00111100
 %00111100
 %00000000
 %00000000
end
    
__MAIN 
    COLUP0 = 120
    m=1 : if joy0fire then m=2
    if joy0up then y = y - m: if y<10 then y=90
    if joy0down then y = y + m: if y>90 then y=10
    if joy0left then x = x - m: if x<10 then x=140
    if joy0right then x = x + m: if x>140 then x=10
    player0x = x : player0y = y
    drawscreen
    goto __MAIN

 

0004 MyGame.txt.bin  

 

What do you guys think?  Please post your comments, below!  

Edited by Living Room Arcade
  • Like 1
Link to comment
Share on other sites

Posted (edited)

Version 0006 - It's green!   

 

Changes

Spoiler
  • Bkg color changed to green
  • P0 sprite changed to a bullseye
  • Score color changed to yellow
  • P0 sprite no longer wraps around the screen
  • Game Reset moves P0 back to center

 

New keyword: switchreset

 

Source

Spoiler

__INTRO x = 75 : y = 50
    COLUBK = $C8
    scorecolor = $1A
    player0:

 %0100010
 %1000001
 %0000000
 %0001000
 %0000000
 %1000001
 %0100010
end
    
__MAIN 
    COLUP0 = $1A
    m=1 : if joy0fire then m=2 
    if joy0up then y = y - m: if y<9 then y= y + m
    if joy0down then y = y + m: if y>89 then y=y-m
    if joy0left then x = x - m: if x<5 then x=x+m
    if joy0right then x = x + m: if x>150 then x=x-m
    player0x = x : player0y = y
    drawscreen
    if switchreset then goto __INTRO
    goto __MAIN

 

Screenshot

Spoiler

image.jpeg.1db2108ae2cb7433a787c7ee1541904c.jpeg

0006 MyGame.txt.bin

 

Post your comments below!  

Edited by Living Room Arcade
  • Like 1
Link to comment
Share on other sites

Are you going for a certain type of game with your experiementation or just testing out the various features?   I haven't started playing around yet with the switches or even much about the playfield (beyond just organizing/making a single screen) as I'm still learning the ins and outs of sprites myself.

Link to comment
Share on other sites

Posted (edited)

@LatchKeyKid Yes, I have decided what kind of game it will be, but just for fun, I don't say.  Try to guess!  :lol: 

 

Update: I have moved my code (such as it is!) from Notepad to VbB.  

 

Screenshot

Spoiler

image.thumb.jpeg.bfccdcbab6a65c0258be20276f0255de.jpeg

 

Nice, huh?  Like a Cadillac!  I'm pretty excited about this!  Thanks, @Random Terrain, I've been using your online guide and so far it's been super helpful!  

Edited by Living Room Arcade
  • Like 3
Link to comment
Share on other sites

Posted (edited)

Okay, it's going to be miniature golf.  (Did you guess? ;-))  

 

I had been doing some thinking about how I want my miniature golf game to work, and this is what I have come up with so far.  

 

The Main Gameplay Sequence

 

Spoiler
  1. The joystick controls P0.  Player one must walk up to the ball and touch it.
  2. Upon touching the ball, P0 drops into a putting stance.  The joystick no longer controls P0.  A bullseye appears midway between P0 and the hole.  The joystick now controls the bullseye.  The player moves the bullseye anywhere he or she desires to aim his or her shot.  When finished aiming, P0 presses the joystick button.
  3. Upon pressing the joystick button, the joystick no longer controls the bullseye.  Now, a power meter appears.  The joystick controls the power meter now.  The player adjusts the power on the power meter and when satisfied, he or she presses the joystick button.
  4. Upon pressing the joystick button, the joystick no longer controls the power meter.  Now, a fast-moving bar appears, as is standard in many golf video games.  The joystick does nothing.  The player tries to press the joystick button at the exact moment that the line crosses the center.  Doing so will give the player a perfect shot.  Pressing the button when the line is on the right will cause the ball to slice to the right.  Pressing the button while the line is on the left will cause the ball to hook to the left.  The main loop waits for the player to press the joystick button.
  5. Upon pressing the joystick button, the bullseye, power meter and hook/slice meter all disappear and the joystick and joystick button do nothing.  P0 goes through a swing animation, a hitting sound is heard, the ball begins moving and P0 stands up.  The ball will lose speed gradually until it stops.  Once the ball has stopped, P0 then returns to his or her natural walking posture, the joystick once again controls the movements of P0, and this sequence goes back to step #1, above, and repeats until P0 puts the ball into the hole.  

 

  • Why must the player walk up to his or her ball after each shot?  So that the player feels that he or she is playing real miniature golf!  In real miniature golf, you have to do this, so in my game, I think it will also seem natural to do this.  

Initially, since this will be my first game, to simplify things, I may simply let P0 be a square like in Warren Robinett's Adventure.  I'm sure that player sprite definitions could replace the square later.  

 

What do you guys think of my outline of the gameplay so far?  Did you guess that my first game would be miniature golf?  Post your comments, below!  

Edited by Living Room Arcade
Link to comment
Share on other sites

Posted (edited)

Oh, and with the difficulty switches in the "b" positions, I'd like each of the players to have three Mulligans.  

 

Spoiler

On difficulty "b," if a player is not satisfied with their last shot and if the player has at least one Mulligan remaining, then the player may retake that shot.  The player's sprite and the ball are returned to their positions before the shot took place.  One stroke is deducted from the scoreboard and the player re-takes the shot immediately.  One Mulligan will then be deducted for the player.  On difficulty "b," a player may do this up to three times during a game.  Doing so is called "taking a Mulligan."  

 

Difficulty Settings

 

Spoiler

Difficulty "b" - "beginner"

  • 3 Mulligans for your player
  • bigger holes
  • hook/slice meter moves slower, making it easier for you to make perfect shots

Difficulty "a" - "advanced"

  • no Mulligans for your player
  • smaller holes
  • hook/slice meter moves faster, making it harder for you to make perfect shots
Edited by Living Room Arcade
Link to comment
Share on other sites

Posted (edited)

Player Sprites - Putting Stances

 

Sketch with notes

 

Spoiler
  • We divide the screen into four quadrants.  The four regions are determined by the location of the bullseye with reference to the location of the ball at that moment.  
  • As the bullseye is moved around by the player using the joystick, the P0 sprite will be changed according to which of the four regions the bullseye has entered, according to the chart below.  
  • The golfer's body positions are all referenced to that of a right-handed golfer.  

image.jpeg.5a498f1b62ab58e92863fab3f64e6370.jpeg

If the bullseye enters region 1

  • Then the golfer will be shown facing you.  The swing will go from left to right.  The ball will go to the right.

If the bullseye enters region 2

  • Then the golfer will be shown facing to the right.  The swing will go along the z-axis in the direction going into the TV screen.  The ball will go up.

If the bullseye enters region 3

  • Then the golfer will be shown with his or her back to you, facing away from you.  The direction of the swing will be from right to left.  The ball will go to the left.

If the bullseye enters region 4

  • Then the golfer will be shown facing to the left.  The direction of the swing will be along the z-axis coming out of the TV screen.  The ball will go down.

Thus, if the human player uses the joystick to move the bullseye counter-clockwise in a circle around the golfer on the TV, then the golfer on the TV will appear to rotate counter-clockwise while standing.  

Edited by Living Room Arcade
Link to comment
Share on other sites

Posted (edited)

Player Sprites - Walking

 

Spoiler

I think this will be sufficient.

 

If the human player moves the joystick to the right

  • Then the golfer is shown walking, facing to the right
  • If the joystick is then moved up or down, the golfer will still face to the right.
  • If the joystick is then moved diagonally to the right, the golfer will still face to the right.

If the human player moves the joystick to the left

  • Then the golfer is shown walking, facing to the left.  
  • If the joystick is then moved up or down, the golfer will still face to the left.
  • If the joystick is then moved diagonally to the left, the golfer will still face to the left.
Edited by Living Room Arcade
Link to comment
Share on other sites

Posted (edited)

Player Sprites - Interacting with Playfield Walls

 

Sketch with notes

 

Spoiler

When the golfer is walking, I would like to use two sprites to draw the complete golfer's body.

  • one sprite just for the golfer's two feet
  • another sprite for the rest of the golfer's body

The golfer's feet will not be allowed to overlap with playfield walls.  The entire remainder of the golfer's body, however, will be allowed to overlap with playfield walls.

 

image.jpeg.a6a948ed12dcc1ae4d5d2d5363fe0af1.jpeg

In the sketch, above, you can see the golfer standing next to two walls.  In situation #1, the golfer stands as close as possible to the lower wall.  His or her feet do not touch the wall.  The remainder of the golfer's body is also not touching the wall.  In situation #2, the golfer stands as close as possible to the upper wall.  The golfer's feet also do not touch the wall; however, almost the entire remainder of the golfer's body is overlapping the wall.  

Edited by Living Room Arcade
Link to comment
Share on other sites

Posted (edited)

Game Reset Required to Change Difficulty Settings

 

Source

 

Spoiler

 set romsize 4k
 set tv ntsc

 

__INTRO x = 75 : y = 50
    COLUBK = $C8
    scorecolor = $1A
 const pfscore = 1
 pfscorecolor = $1A
  pfscore1=%00000000 :  if switchleftb then pfscore1 = %00010101
  pfscore2=%00000000 :  if switchrightb then pfscore2 = %10101000

 

    player0:

 %0100010
 %1000001
 %0000000
 %0001000
 %0000000
 %1000001
 %0100010
end
    
__MAIN 
    COLUP0 = $1A
    m=1 : if joy0fire then m=2 
    if joy0up then y = y - m: if y<9 then y= y + m
    if joy0down then y = y + m: if y>89 then y=y-m
    if joy0left then x = x - m: if x<5 then x=x+m
    if joy0right then x = x + m: if x>150 then x=x-m
    player0x = x : player0y = y
    drawscreen
    if switchreset then goto __INTRO
    goto __MAIN

0007minigolf.bas.bin

Edited by Living Room Arcade
Link to comment
Share on other sites

Out of curiosity, which bB kernel are you using?    I ask because the default is the aptly named standard kernel but, if you're not planning on using some of the kernel options it focuses on, I think the genre of game might benefit alot from the multisprite if you're not scrolling playfields with the shots.

  • Like 1
Link to comment
Share on other sites

1 hour ago, LatchKeyKid said:

Out of curiosity, which bB kernel are you using?    I ask because the default is the aptly named standard kernel but, if you're not planning on using some of the kernel options it focuses on, I think the genre of game might benefit alot from the multisprite if you're not scrolling playfields with the shots.

Thank you for suggesting the multisprite kernel!  Currently using the standard kernel.  I've got links here for RT's kernel option chart and multisprite kernel info.  Currently weighing the pros and cons.  Thanks very much for the tip!  

Link to comment
Share on other sites

Posted (edited)

@LatchKeyKid  Thank you, the information you linked was exactly what I needed.  

 

I removed the outer walls.  I wonder if something like this could work.  Let the players use the entire screen.  

 

IMG1_300x225.jpg.4e8d3fb9aa331fc2846ad389103dc045.jpg

In addition to collision checks with playfield walls, the main loop could also check if the ball has touched the outer edges of the screen and if so then let the ball bounce off as if there were walls there.  Whaddaya guys think?  

Edited by Living Room Arcade
  • Like 1
Link to comment
Share on other sites

Posted (edited)

Super Chip Double-Height Playfield Test

image.jpeg.b25113f5df43457125a3a97098289a24.jpeg

Source

Spoiler

 set romsize 8kSC
 set tv ntsc

__INTRO x = 75 : y = 50
    COLUBK = $C8
    scorecolor = $1A
 const pfscore = 1
 const pfres=24
 pfscorecolor = $1A
  pfscore1=%00000000 :  if switchleftb then pfscore1 = %00010101
  pfscore2=%00000000 :  if switchrightb then pfscore2 = %10101000

 playfield:
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........X.....................X
 X........XX....................X
 X.........XXXXXXXXXXXXXXX......X
 X..............................X
 X..............................X
 X..............................X
 XX.............................X
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

 player0:

 %0100010
 %1000001
 %0000000
 %0001000
 %0000000
 %1000001
 %0100010
end
    
__MAIN 
    COLUP0 = $1A
    m=1 : if joy0fire then m=2 
    if joy0up then y = y - m: if y<9 then y= y + m
    if joy0down then y = y + m: if y>93 then y=y-m
    if joy0left then x = x - m: if x<5 then x=x+m
    if joy0right then x = x + m: if x>150 then x=x-m
    player0x = x : player0y = y
    drawscreen
    if switchreset then goto __INTRO
    goto __MAIN

0008_SC_PF_Test.bas.bin

Edited by Living Room Arcade
Link to comment
Share on other sites

Posted (edited)

DPC+ Playfield Test

image.jpeg.988b4110f265c794e52e861672d787ae.jpeg

Source

Spoiler

   

   ;****************************************************************
   ;
   ;  This program uses the DPC+ kernel.
   ;
   set kernel DPC+

   ;****************************************************************
   ;
   ;  Standard used in North America and most of South America.
   ;
   set tv ntsc

   ;****************************************************************
   ;
   ;  Helps player1 sprites register a collision with the playfield.
   ;
   set kernel_options collision(player1,playfield)

   ;***************************************************************
   ;
   ;  Variable aliases go here (DIMs).
   ;
   ;***************************************************************
   ;
   ;  (You can have more than one alias for each variable.)
   ;


   goto __Bank_2 bank2

   bank 2
   temp1=temp1

__Bank_2

   ;***************************************************************
   ;***************************************************************
   ;
   ;  Program Start/Restart
   ;
__Start_Restart


   ;***************************************************************
   ;
   ;  Displays the screen to avoid going over 262 when reset.
   ;
   drawscreen


   ;***************************************************************
   ;
   ;  Clears the playfield.
   ;
   pfclear


   ;***************************************************************
   ;
   ;  Mutes volume of both sound channels.
   ;
   AUDV0 = 0 : AUDV1 = 0


   ;***************************************************************
   ;
   ;  Clears all normal variables and the extra 9.
   ;
   a = 0 : b = 0 : c = 0 : d = 0 : e = 0 : f = 0 : g = 0 : h = 0 : i = 0
   j = 0 : k = 0 : l = 0 : m = 0 : n = 0 : o = 0 : p = 0 : q = 0 : r = 0
   s = 0 : t = 0 : u = 0 : v = 0 : w = 0 : x = 0 : y = 0 : z = 0
   var0 = 0 : var1 = 0 : var2 = 0 : var3 = 0 : var4 = 0
   var5 = 0 : var6 = 0 : var7 = 0 : var8 = 0


   ;***************************************************************
   ;
   ;  Playfield data.
   ;
   playfield:
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........X...................X
 X..........XX..................X
 X..........XX..................X
 X...........XX.................X
 X...........XX.................X
 X............XX................X
 X............XX................X
 X.............XX...............X
 X.............XX...............X
 X..............XXXXX...........X
 X..............XXXXX...........X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 X..............................X
 XX.............................X
 XXX............................X
 XXXX...........................X
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end


   ;***************************************************************
   ;
   ;  Playfield colors.
   ;
   pfcolors:
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
end


   ;***************************************************************
   ;
   ;  Background colors.
   ;
   bkcolors:
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
   $C8
end

   scorecolors:
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
   $1A
end


   ;***************************************************************
   ;***************************************************************
   ;
   ;  Main Loop
   ;
__Main_Loop

   ;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   ;```````````````````````````````````````````````````````````````
   ;
   ;  Gameplay logic goes here.
   ;
   ;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
   ;```````````````````````````````````````````````````````````````


   ;***************************************************************
   ;
   ;  88 rows that are 2 scanlines high.
   ;
   DF6FRACINC = 255 ; Background colors.
   DF4FRACINC = 255 ; Playfield colors.

   DF0FRACINC = 128 ; Column 0.
   DF1FRACINC = 128 ; Column 1.
   DF2FRACINC = 128 ; Column 2.
   DF3FRACINC = 128 ; Column 3.


   ;***************************************************************
   ;
   ;  Displays the screen.
   ;
   drawscreen


   ;```````````````````````````````````````````````````````````````
   ;  Restarts the program.
   ;
   goto __Start_Restart

   bank 3
   temp1=temp1

   bank 4
   temp1=temp1

   bank 5
   temp1=temp1

   bank 6
   temp1=temp1

dpc_playfield_test.bas.bin

Edited by Living Room Arcade
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...