Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- --------------------------------------------------------------
- funtion to show the menu on the screen for the user to see
- ----------------------------------------------------
- ]]
- function display_menu()
- -- Display a menu on the console
- print("+----------------------------------")
- print("| Welcome, brave soul, today is "..os.date())
- print("+----------------------------------")
- print("| 1.Generate random enemy position")
- print("| 2.Distance from enemy to player")
- print("| 3.Get angle from enemy to player")
- print("| 4.Exit")
- print("+----------------------------------")
- end
- --[[
- My InSaNe code
- jk... its really not that P but idk
- just a starter
- ]]
- math.random(os.time())
- --delcaring player pos in the middle of the screen
- local player_x, player_y = 400,300
- local enemy_x, enemy_y = 0,0
- local user_option = 0
- --loop while user option is different
- while user_option ~= 4 do
- display_menu()
- --read the user option from the keyboard
- print("Please, select your option:")
- user_option = io.read("*n")
- if user_option == 1 then
- enemy_x = math.random(0, 800)
- enemy_y = math.random(0, 600)
- print("New enemy pos ("..enemy_x..","..enemy_y..")")
- end
- if user_option == 2 then
- local d = math.sqrt((enemy_x-player_x)^2 + (enemy_y-player_y)^2)
- print("Distance from enemy to player: "..d)
- end
- if user_option == 3 then
- local a = math.atan2((enemy_y-player_y) (enemy_x-player_x))
- local a_deg = math.deg(a)
- print("Angle between enemy and player is: ".. a_deg.." degrees")
- end
- end
- -- quick little user survey
- print("+----------------------------------")
- print("Please take a quick minute to fill out this short survey")
- print("+----------------------------------")
- print("1.The program was good")
- print("2.The program was bad")
- print("3.Take me out of this trash program once and for all")
- survey_answer = io.read("*n")
- if survey_answer == 1 then
- print("+----------------------------------")
- print("GLAD TO HEAR THAT, goodbye")
- print("+----------------------------------")
- end
- if survey_answer == 2 then
- print("+----------------------------------")
- print("AWW sorry to hear that")
- print("+----------------------------------")
- end
- if survey_answer == 3 then
- print("+----------------------------------")
- print("GOODBYE!!")
- print("+----------------------------------")
- os.exit()
- end
- print("Thank you for your time, goodbye!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement