Jump to content
IGNORED

Basketball engine - Dribble handling


Recommended Posts

Experimenting with a basketball engine, I got dribbling half-working, as long as you move left or right it works, but when you move up or down the ball won't move up and down anymore, any ideas?

 

 set kernel_option no_blank_lines

 player0y = 50: player0x = 50
 a = 10

 ballx = 80 : bally= 50

 dim p1_own_ball = c
 dim p1_shoot_ball = d

 dim ball_bounce = e

 p1_own_ball = 0
main

 ballheight = 4
 CTRLPF = $21

 COLUBK=$86
 COLUPF=$26
 COLUP0=$0E

 if a = 10 then player0:
 %00000000
 %00000000
 %00110000
 %00100000
 %01010000
 %01111100
 %00001110
 %00011100
 %00011000
 %00011000
 %10011011
 %10011100
 %01011000
 %00000000
 %00011000
 %00011000
end

 if a = 20 then player0:
 %00000000
 %00000000
 %00110110
 %00100100
 %00010010
 %00010100
 %00001100
 %00011000
 %00011000
 %00011000
 %10011011
 %10011100
 %01011000
 %00000000
 %00011000
 %00011000
end



 playfield:
 ................................
 ................................
 ..X..........................X..
 ..XX........................XX..
 ..X..........................X..
 ..X..........................X..
 ..X..........................X..
 ................................
 ................................
 ................................
 ................................
end



 if a = 30 then a = 0

 drawscreen

 rem PLAYER0 ANIMATION FRAME COUNTER
 a = a + 1

 rem flip player0 sprite
 if b = 0 then REFP0 = 0
 if b = 1 then REFP0 = 8

 rem PLAYER0 CONTROLS
 if joy0right then player0x = player0x + 1 : b = 0
 if joy0left then player0x = player0x - 1 : b = 1
 if joy0up then player0y = player0y - 1
 if joy0down then player0y = player0y + 1

 if collision(player0,ball) && p1_own_ball = 0 then p1_own_ball = 1 : ball_bounce = 2
 if p1_own_ball = 1 && b = 0 then ballx = player0x + 9
 if p1_own_ball = 1 && b = 1 then ballx = player0x - 2
 rem ball bounces up
 if p1_own_ball = 1 && bally > player0y-1 then ball_bounce = 1
 rem ball bounces down
 if p1_own_ball = 1 && bally < player0y - 5 then ball_bounce = 2


 if p1_own_ball = 1 && ball_bounce = 1 then bally = bally - 1
 if p1_own_ball = 1 && ball_bounce = 2 then bally = bally + 1


 goto main

Source: Bball.bas

 

Bin: Bball.bin

Link to comment
https://forums.atariage.com/topic/324034-basketball-engine-dribble-handling/
Share on other sites

Fixed the issue by slowing down the player. Dribbling works flawlessly now, and by pushing the joystick you can now jump with the ball to line up a shot.

Capture.PNG.fb6775c63b751341e223fc5a69fe06ff.PNG

Source:Bball 0.2.bas

Bin: Bball 0.2.bin

 

Feel free too use the source in order to help you make your own game of basketball.

  • Like 1

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...