Jump to content
IGNORED

I need sample code moving the ball in a game


bluetriforce

Recommended Posts

Hi,

 

For weeks I am trying to make the ball moving across the screen in a small path across the screen? I am almost new to batari basic. This is my source code

 

 dim dirx = a
COLUPF = 204 : score = 0
ballx = 20 : bally = 20 
dirx = 1
bally = 20 : ballheight = 1
gameloop
scorecolor = 158
drawscreen
ballx = ballx + 1
if ballx < 40 then dirx = dirx + 1
goto gameloop

 

 

Thanks :)

Link to comment
Share on other sites

Hi,

 

For weeks I am trying to make the ball moving across the screen in a small path across the screen?  I am almost new to batari basic.  This is my source code

 

965737[/snapback]

I assume you want dirx to be the ball's direction. To bounce the ball back and forth between ballx=20 and ballx=40, for instance, you can change your program to this:

 

  dim dirx = a
 COLUPF = 204 : score = 0
 ballx = 20 : bally = 20 
 dirx = 1
 bally = 20 : ballheight = 1
gameloop
 scorecolor = 158
 drawscreen
 ballx = ballx + dirx
 if ballx < 20 || ballx > 40 then dirx = 0 - dirx
 goto gameloop

Edited by batari
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...