atheorist (atheorist) wrote,
atheorist
atheorist

the pong tutorial in clickteam's the games factory 2


  1. create a new game (control-n)
  2. click on it to see the properties on the left
  3. change the background color to black (settings/background color/black)
  4. switch to the frame editor (control-m)
  5. add an active object (alt-i, o, act, tab, enter, click)
  6. change movement to bouncing ball
  7. change speed to 40
  8. switch to the event editor (control-e)
  9. based on the ball, create a new condition, position, select all arrows pointing away from the center
  10. based on the ball, create a new action, movement, bounce
  11. go back to the frame editor (control-m)
  12. add a paddle to the playarea (alt-i, o, act, tab, enter, click)
  13. clone the paddle to somewhere else?
  14. select both paddles
  15. set their movement to eight directions
  16. change the right paddle's player property to 2
  17. change the game's properties - runtime options/player controls/player 2 should be wasd
  18. change back to the event editor (control-e)
  19. add a condition, based on one of the paddles, collision with / another object / the ball
  20. use the same action, bounce
  21. do the same thing with the other paddle (or drag the event you just made down to event 3 and change the other paddle instead)
  22. change the original bounce condition to not bounce when hitting left and right
  23. add a new condition that, if the ball leaves the play area on the left or right, it gets centered in the screen
  24. add a new condition that, if the ball leaves the play area on the left, the number of lives for player 1 gets decreased
  25. add a new condition that, if the ball leaves the play area on the right, the number of lives for player 2 gets decreased
  26. add a new condition that, if player 1's lives are zero, then storyboard controls / end the application
  27. add a new condition that, if player 2's lives are zero, then storyboard controls / end the application
  28. switch to the frame editor (control-m)
  29. insert a lives object (alt-i, o, liv, tab, enter, click)
  30. clone the lives object, place it above player 2 and change it to player 2
  31. -- TODO: add a background
  32. -- TODO: add sounds to the events



require 'framework'

-- create a new game (control-n)
the_game = new_game()
-- change the project default frame 1 to a black background
the_frame = the_game.frames[1]
the_frame.background = BLACK
-- make an active object
ball = new_active{ x = 320, y = 240 }
-- give the active object the 4-direction movement
ball.movement = BOUNCING_BALL
ball.movement.speed = 40
table.insert(the_frame.objects, player)
-- if the ball leaves the frame via the top or bottom, it instead bounces
table.insert(the_frame.events,
  new_event(ball:position{LEAVE_TOP, LEAVE_BOTTOM}):add_action(ball:movement(BOUNCE))
)
paddle_1 = new_active{ x = 100, y = 240 }
paddle_1.movement = EIGHT_DIRECTIONS
paddle_2 = new_active{ x = 540, y = 240 }
paddle_2.player = 2
the_game.runtime_options.player_controls.player[2] = WASD
table.insert(the_frame.events,
  new_event(paddle_1:collision_with(another_object(ball))):add_action(ball:movement(BOUNCE))
)
table.insert(the_frame.events,
  new_event(paddle_2:collision_with(another_object(ball))):add_action(ball:movement(BOUNCE))
)
-- if the ball leaves the play area on the left or right, it gets centered in the screen
table.insert(the_frame.events,
  new_event(ball:position{LEAVE_LEFT, LEAVE_RIGHT}):add_action(ball:position{x = 320, y = 240})
)
-- if the ball leaves the play area on the left, lives for player 1 gets decreased
table.insert(the_frame.events,
  new_event(ball:position{LEAVE_LEFT}):add_action(the_game.player[1]:subtract_lives(1))
)
-- if the ball leaves the play area on the right, lives for player 2 gets decreased
table.insert(the_frame.events,
  new_event(ball:position{LEAVE_LEFT}):add_action(the_game.player[2]:subtract_lives(1))
)
-- if player 1's lives are zero, then end the game
table.insert(the_frame.events,
  new_event(the_game.player[1]:lives_equal_zero()):add_action(the_game:end())
)
-- if player 2's lives are zero, then end the game
table.insert(the_frame.events,
  new_event(the_game.player[2]:lives_equal_zero()):add_action(the_game:end())
)
]]
--[[ TODO
-- switch to the frame editor (control-m)
-- insert a lives object (alt-i, o, liv, tab, enter, click)
-- clone the lives object, place it above player 2 and change it to player 2
-- TODO: add a background
-- TODO: add sounds to the events
]]

the_game:run()
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 0 comments