Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A game of pool...
#1
Here's a pool game that I have been working on. You can play against another player, or the computer.

I've tried to include playing hints that show up as you play - there's no time pressure, so you can take the time to read these as they appear in the lower part of the screen.

The main control is the mouse or trackpad. When it is your turn to play, press AND HOLD DOWN the left mouse button to lift the pool cue. You can then position the cue by using the mouse, while keeping the mouse button pressed down. The further away from the white ball the mouse goes, the more powerful the shot will be. When you are happy with the mouse position, release the mouse button to take the shot.

There's no image files needed, so you can just run the n7 file from the zip, or use the executable.

   


.zip   pool.zip (Size: 842.52 KB / Downloads: 8)
Reply
#2
Walking home from work now. First thing I'm going to do when I get home is to try it. Been waiting for this one and my expectations are super high Big Grin
Reply
#3
(02-22-2024, 02:16 PM)kevin Wrote: Here's a pool game that I have been working on. You can play against another player, or the computer.

...

Glad to have another type of game in N7, I can't wait to try it as soon as possible ....
Reply
#4
This is probably the most advanced game every written in naalaa, I am truely impressed and I bow to you Smile I didn't expect a computer opponent, and I certainly didn't expect it to beat me - which it did!

Now I'm forced to write an even more advanced game, dammet!

Well done!

Edit Am I allowed to put it in the examples folder?
Reply
#5
Sure, no problem, I 'd like that.
This was the first time that I have tried to implement a computer opponent, and I really enjoyed the challenge. It's difficult to judge how skillful to make it - I think next time it would be good to have different levels of difficulty, but that's for a future project.....
Reply
#6
Kevin:

I actually beat the computer! I cleared all the yellow balls and was left with only the black. The computer had not scored... Then the computer seemed to be "demon possessed" and immediately cleared all the red balls... I only won because the computer missed its shot...

Very well done!

Marcus:

"more advanced", you say? I have a joystick gathering dust... perhaps a Flight Sim? Moo Ha Ha Ha...

J
Logic is the beginning of wisdom.
Reply
#7
(02-22-2024, 02:16 PM)kevin Wrote: Here's a pool game that I have been working on. You can play against another player, or the computer.
...

Hi Kevin,
You made a cheat_mode in your game ... I like it  Big Grin

Or even you could make it like an easter egg, too ... a secret key F5, so the computer would assist you to play your turn

Code:
'----------------------
'  GAME LOOP
'----------------------
do
...
'Secret key F5, so you as Player_1, let the computer plays for you.
if keydown(KEY_F5) then computer_opponent()
...
until keydown(KEY_ESCAPE)


'-----------
' FUNCTIONS
'-----------
function computer_oppenent()
...
    if balls[b].active_now
        if player1.colour="red" or player2.colour = "red" and can_play = true
            if b = 0 or b = 2 or b = 6 or b = 8 or b = 9 or b = 13 or b = 14
                 target_balls[sizeof(target_balls)] = b
            endif
        elseif player1.colour="yellow" or player2.colour = "yellow"
            if b = 1 or b = 3 or b = 4 or b = 5 or b = 7 or b = 11 or b = 12
                target_balls[sizeof(target_balls)] = b
            endif
        endif
    endif
    ...
   'select a target ball, with nothing blocking it, and aim for it
   'calculate the unblocked ball that is closest to a pocket
    ...
endfunc
Reply
#8
(02-25-2024, 07:09 AM)1micha.elok Wrote: You made a cheat_mode in your game ... I like it  Big Grin

Or even you could make it like an easter egg, too ... a secret key F5, so the computer would assist you to play your turn

That's a very good idea. In a similar way, I think it may have been good to include a demo mode in the menu screen, where you could watch a whole computer v computer frame being played out - this would give players a good idea how the game should be played. More ideas for future projects - thank you.
Reply
#9
(02-22-2024, 07:20 PM)johnno56 Wrote: "more advanced"...

more advanced...perhaps a 3D-Pool  Big Grin

I just realized that making a 3D-Pool need a lot of different angles of 3D sprite sheet balls 
... and when I tried to animate a 3D ball rotated on its axis ... it exploded  Big Grin Big Grin Big Grin  [ Just my fantasy ]

Code:
'Source :
'3D Ball Sprite Sheet https://emunix.emich.edu/~evett/GameProgramming/BookCode/chapter11.new/multithread/sphere.bmp
'Explosion Sprite Sheet http://www.nordenfelt-thegame.com/blog/wp-content/uploads/2011/11/explosion_opaque.png

'----------------
' INITIALIZATION
'----------------
#win32
set window "Ball",200,200,false
set redraw off

cGreen = [0,128,0]
cWhite = [255,255,255]

'Sprite class definition
Sprite =
[
    '---- Properties ----
    img :loadimage("img/ball.png",8,4),
    x   :width(primary)/2-30,
    y   :height(primary)/2-30,
    sf  :0 'speed factor of rotation
]

Ball            = copy(Sprite)
Explosion       = copy(Sprite)
  Explosion.img = loadimage("img/explosion.png",5,5)
  Explosion.x   = Sprite.x-60
  Explosion.y   = Sprite.y-60

'----------------
'  MAIN PROGRAM
'----------------
do
    set color cGreen;cls;set color cWhite

    'ball rotates on its axis
    'the state of rotation : fast, slow then stop.
    for i = 0 to 31
        'set color cWhite
        draw image Ball.img,Ball.x,Ball.y,i 
        redraw
         
        Ball.speed = 200 - Ball.sf
        set caret 10,10;wln "Speed : "+Ball.speed
        fwait Ball.speed
    next
   
    'explosion visual effect
    Ball.sf = Ball.sf + 5
    if Ball.speed = 5 then
        for i = 0 to 24
            draw image Explosion.img,Explosion.x,Explosion.y,i
            fwait 10
            redraw
        next
        end
    endif
loop


Attached Files
.zip   3D Ball.zip (Size: 136.62 KB / Downloads: 3)
Reply
#10
Nice demo.. Cool...

Your animation reminded me of a game I was given almost a quarter of a century ago (24 years)... Maximum Pool... There were "non-conventional" pool games that included exploding pool balls... Thanks for the memories...
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)