require "collistion"
function love.load()
love.window.setTitle("mouse game")
love.mouse.setVisible(false)
mouse_img = love.graphics.newImage("mouse1.png")
text = 0
test = 0
text_pose = {}
text_pose.x = 350
text_pose.y = 500
game_1_timer = 60--mini game one vars and tables
player_game_1_hp = 5
one_time_1 = 0
start_mini_game = 0
test_1 = {}
test_1.x = 300
test_1.y = 300
test_1.w = 15
test_1.h = 15
player_mini_game_1 = {}
player_mini_game_1.x = 0
player_mini_game_1.y = 0
player_mini_game_1.speed = 5
player_mini_game_1.w = 20
player_mini_game_1.h = 20
enemy_mini_game_1 = {}
enemy_mini_game_1.x = 0
enemy_mini_game_1.y = 0
enemy_mini_game_1.w = 10
enemy_mini_game_1.h = 10
end
function love.update(dt)
if text > 3 then--starting first part of the game
start_mini_game = 1
end
if start_mini_game == 1 then--mini game 1
if player_game_1_hp < 1 then
love.event.quit( "restart" )
end
game_1_timer = game_1_timer - 0.015--timer for mini game 1
--colider for mini game 1
if not AABB(player_mini_game_1.x, player_mini_game_1.y, player_mini_game_1.w, player_mini_game_1.h, test_1.x, test_1.y, test_1.w, test_1.h) then
one_time_1 = 0
end
if AABB(player_mini_game_1.x, player_mini_game_1.y, player_mini_game_1.w, player_mini_game_1.h, test_1.x, test_1.y, test_1.w, test_1.h) then
if one_time_1 == 0 then
player_game_1_hp = player_game_1_hp - 1
one_time_1 = 1
end
end
-- calculate angle from enemy to player
local angle = love.math.getAngle(enemy_mini_game_1.x, enemy_mini_game_1.y, player_mini_game_1.x, player_mini_game_1.y)
-- work out how much x and y will change in this step
-- math.cos and math.sin will be between -1 and +1
-- multiplying by (dt*speed) means the enemy will move speed pixels in one whole second
local dx = math.cos(angle) * (dt * speed)
local dy = math.sin(angle) * (dt * speed)
-- move to our new x and y
enemy_mini_game_1.x = enemy_mini_game_1.x + dx
enemy_mini_game_1.y = enemy_mini_game_1.y + dy
end
end
function love.draw()
love.graphics.setColor(1, 0.3, 0.3)--player hp
gameFont_1 = love.graphics.newFont(40)
love.graphics.setFont(gameFont_1)--makes text bigger
love.graphics.print(player_game_1_hp, 385, 0)
if start_mini_game < 1 then--befor mini game start
love.graphics.setColor(0.7, 0.4, 0.1)
love.graphics.rectangle("fill", 20, 450, 760, 128)--text box
gameFont_2 = love.graphics.newFont(10)
love.graphics.setFont(gameFont_2)--makes text bigger
love.graphics.setColor(1, 1, 1)
love.graphics.print("space 4 next", 665, 540)--space 4 next
local x, y = love.mouse.getPosition()--gets mouse pose
love.graphics.draw(mouse_img, x, y, -1.5, 0.1)
end
gameFont_3 = love.graphics.newFont(5)--makes text bigger
love.graphics.setFont(gameFont_3)
love.graphics.setColor(1, 1, 1)--test
love.graphics.print(text,0,0)
love.graphics.print(start_mini_game, 0, 20)--test
if text == 0 then
love.graphics.print("press ''space'' to continue.", 2, 30)--tels player to go foward
end
gameFont_2 = love.graphics.newFont(12)--makes text bigger
love.graphics.setFont(gameFont_2)
--start of placeholder diolog
if text == 1 then
love.graphics.print("(placeholdre)YOU no not U but the MOUSE CURSOR you have all the attention", text_pose.x - 160, text_pose.y)
end
if text == 2 then
love.graphics.print("(placeholdre)But when you are gon I will be the favorit on the computer!!!", text_pose.x - 160, text_pose.y)
end
if text == 3 then
love.graphics.print("lets see if you can pass my 3 challenges! :{", text_pose.x - 100 , text_pose.y)
end
--game 1
if start_mini_game == 1 then
love.graphics.print(game_1_timer, 500 ,500)
if game_1_timer > 0 then
love.graphics.rectangle("fill", test_1.x, test_1.y, test_1.w, test_1.h)
end
local x, y = love.mouse.getPosition()
player_mini_game_1.x = x
player_mini_game_1.y = y
love.graphics.rectangle("fill", player_mini_game_1.x, player_mini_game_1.y, player_mini_game_1.w, player_mini_game_1.h)
end
end
function love.keypressed(key)--keyboard
if key=="space" then
text = text + 1
end
end
my code dose not work I need someone who is more experianced then me to help me
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: my code dose not work I need someone who is more experianced then me to help me
Please create a .love file and attach it to your post. There is a tutorial in the wiki: How to Create a .love-file. Then everything is packed together (your code, the collision library and the images) and we can take a look what is going on.
And please describe your problem: What is happening and what should happen?
And please describe your problem: What is happening and what should happen?
- NoreoAlles
- Party member
- Posts: 107
- Joined: Mon Jan 03, 2022 5:42 pm
Re: my code dose not work I need someone who is more experianced then me to help me
hey, i didnt look at youre code in detail but it seems like in the beginning "require "collistion"" should be "require "collision", so no "t". Please upload the error youre getting.
"Why do they call it oven when you of in the cold food of out hot eat the food?" - Jon Arbuckle
Re: my code dose not work I need someone who is more experianced then me to help me
Also, please wrap your code in [code][/code] tags in the forum. It makes the code easier to read.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
Who is online
Users browsing this forum: No registered users and 30 guests