Hodgey, I am gonna sound like a child here but...I DID IT!! Your example worked like a charm, well sort of. Even in your sample code:
if speedx < 0 then dec speedx, 1
if speedx > 0 then inc speedx, 1
if speedy < 0 then dec speedy, 1
if speedy > 0 then inc speedy, 1
The "1" was producing hectic results. I had to change the the speedx and y from an integer to a real number in order to slow it down even further. I also had to add in a real variable that represents the speed of the paddles so I could modify that in the game speed function as well. Game runs as intended with the exception of the timer does not reset back to 60 upon a missed ball. I'm still working on that lol.
Thank you my friend.
Quote: "She might be interested in The 3D Game Maker. It's very basic (and written in DarkBASIC I think) but I think she'd have a blast with it. "
I will def check that out!
Modified full code:
set_glob_var()
display_splash_screen()
sync off rem Disables auto screen refresh
sync rate 60 rem set screen refresh rate
init_time#=timer()/1000
global time#=init_time#
do rem Main program loop
cls
process_player_moves()
update_ball_position()
manage_vertical_collisions()
process_player_misses()
draw_ball_and_paddles()
process_player_hits()
update_score()
if (playeronepoints = 10) or (playertwopoints = 10) then end_of_game()
rem collect updated time
time#=timer()/1000-init_time#
rem to make it count down from a value just minus time from that value
rem e.g.
time#=60-time#
rem convert to minuits and seconds
min=floor(time#/60)
sec=floor(time#-min*60)
text 280,10,"Time: "+str$(sec)
if sec = 0
increase_game_speed()
endif
sync rem Refreshes the screen each time it loops to update changes made
loop
function increase_game_speed()
if speedx < 0 then dec speedx, 0.05
if speedx > 0 then inc speedx, 0.05
if speedy < 0 then dec speedy, 0.05
if speedy > 0 then inc speedy, 0.05
inc paddlespeed, 0.05
endfunction
function end_of_game()
sync off rem turn off auto refresh
cls
set text size 48
center text 320, 120, "Game Over!"
set text size 24
center text 320, 210, "Player 1: " + str$(playeronepoints) + " points"
center text 320, 240, "Player 2: " + str$(playertwopoints) + " points"
set text size 16
center text 320, 300, "press any key"
wait key
playeronepoints = 0
playertwopoints = 0
cls
sync on
end
endfunction
function update_score()
text 50, 10, "Player 1: " + str$(playeronepoints) + " points"
text 440, 10, "Player 2: " + str$(playertwopoints) + " points"
endfunction
function reset_ball_and_paddles()
ballx = 320
bally = 240
speedx = 3.0
speedy = 3.0
paddlex1 = 625
paddley1 = 200
paddlex2 = 5
paddley2 = 200
paddlespeed = 5.0
endfunction
function process_player_hits()
rem if the background color behind ball is not black then the ball has hit the paddle
if point(ballx, bally) > 0
rem reverse ball direction when it hit paddle
speedx = speedx * -1
play sound 1
endif
endfunction
function draw_ball_and_paddles()
circle ballx, bally, 8
box paddlex1, paddley1, paddlex1 + 10, paddley1 + 75
box paddlex2, paddley2, paddlex2 + 10, paddley2 + 75
endfunction
function display_splash_screen()
set text size 48
center text 320, 170, "Welcome to PONG!!"
set text size 16
center text 320, 250, "Press any key"
wait key
cls
endfunction
function process_player_misses()
if ballx < 9
play sound 2
inc playertwopoints, 1
reset_ball_and_paddles()
rem speedx = 3.0
sleep 2000
endif
if ballx > 631
play sound 2
inc playeronepoints, 1
reset_ball_and_paddles()
rem speedx = -3.0
sleep 2000
endif
endfunction
function manage_vertical_collisions()
rem This function reverses the vertical direction of the ball when it touches top or bottom of screen
if bally < 5 or bally > 475 rem if ball hits top or bottom
speedy = speedy * -1 rem reverse the vertical direction
play sound 1
endif
endfunction
function update_ball_position()
rem This function is responsible for updating the ball as it bounces around
inc ballx, speedx rem move the ball further along it's current direction on the horiz axis
inc bally, speedy rem move the ball further along on the vert axis
endfunction
function process_player_moves()
rem This function is responsible for controlling the movement of the paddles
if shiftkey()
dec paddley2, paddlespeed
if paddley2 < 0 then paddley2 = 0
endif
if controlkey()
inc paddley2, paddlespeed
if paddley2 > 405 then paddley2 = 405
endif
if upkey()
dec paddley1, paddlespeed
if paddley1 < 0 then paddley1 = 0
endif
if downkey()
inc paddley1, paddlespeed
if paddley1 > 405 then paddley1 = 405
endif
endfunction
function set_glob_var()
global playeronepoints as integer = 0
global playertwopoints as integer = 0
global ballx as integer = 320
global bally as integer = 240
global speedx as float = 3.0
global speedy as float = 3.0
global paddlex1 as integer = 625
global paddley1 as integer = 200
global paddlex2 as integer = 5
global paddley2 as integer = 200
global paddlespeed as float = 5.0
ink rgb(255, 255, 0), 0
load sound "C:\Program Files\The Game Creators\Dark Basic Professional\Projects\Pong\media\type.wav", 1
load sound "C:\Program Files\The Game Creators\Dark Basic Professional\Projects\Pong\media\fire.wav", 2
set sound volume 1, 100
set sound volume 2, 85
hide mouse
endfunction
[quote][/quote]