Difference between revisions of "love.image"

m (See Also: Reorder links.)
Line 1: Line 1:
Provides an interface to decode encoded image data.
+
local opponents = {
== Types ==
+
  {name = "Itadori", image = "characters/itadori.png", selected = false},
{{#ask: [[Category:Types]] [[parent::love.image]] [[Concept:Current]]
+
  {name = "Megumi", image = "characters/megumi.png", selected = false},
| headers=hide
+
  {name = "Nobara", image = "characters/nobara.png", selected = false},
| format=template
+
  {name = "Choso", image = "characters/choso.png", selected = false}
| template=ListingFields
+
}
| introtemplate=ListingIntro
 
| outrotemplate=ListingOutro
 
| ?Description
 
| ?PrettySince
 
| ?PrettyRemoved
 
}}
 
== Functions ==
 
{{#ask: [[Category:Functions]] [[parent::love.image]] [[Concept:Current]]
 
| headers=hide
 
| format=template
 
| template=ListingFields
 
| introtemplate=ListingIntro
 
| outrotemplate=ListingOutro
 
| ?Description
 
| ?PrettySince
 
| ?PrettyRemoved
 
}}
 
== Enums ==
 
{{#ask: [[Category:Enums]] [[parent::love.image]] [[Concept:Current]]
 
| headers=hide
 
| format=template
 
| template=ListingFields
 
| introtemplate=ListingIntro
 
| outrotemplate=ListingOutro
 
| ?Description
 
| ?PrettySince
 
| ?PrettyRemoved
 
}}
 
== See Also ==
 
* [[parent::love]]
 
* [[Image]] - the love.graphics data type
 
* [[Image Formats]]
 
* [[love.graphics.newImage]]
 
[[Category:Modules]]
 
{{#set:Description=Provides an interface to decode encoded image data.}}
 
{{#set:Since=000}}
 
  
== Other Languages ==
+
local player = {
{{i18n|love.image}}
+
  name = "Your Character",
 +
  level = 1
 +
}
 +
 
 +
local characterImages = {}
 +
 
 +
function love.load()
 +
  for i, opponent in ipairs(opponents) do
 +
    characterImages[i] = love.graphics.newImage(opponent.image)
 +
  end
 +
end
 +
 
 +
function drawCharacter(characterImage, x, y, scale)
 +
  love.graphics.draw(characterImage, x, y, 0, scale, scale)
 +
end
 +
 
 +
function love.draw()
 +
  -- Draw the player character
 +
  drawCharacter(characterImages[1], 50, 50, 1)
 +
 
 +
  -- Draw any opponent characters that have been selected
 +
  for i, opponent in ipairs(opponents) do
 +
    if opponent.selected then
 +
      drawCharacter(characterImages[i], 300, 50 * i, 1)
 +
    end
 +
  end
 +
end
 +
 
 +
function displayMenu()
 +
  -- Print menu options
 +
  for i, opponent in ipairs(opponents) do
 +
    print(i .. ". Select " .. opponent.name)
 +
  end
 +
  print("5. Quit")
 +
 
 +
  -- Get user choice
 +
  io.write("Enter your choice: ")
 +
  local choice = io.read()
 +
  choice = tonumber(choice)
 +
 
 +
  -- Perform actions based on choice
 +
  if choice == 1 then
 +
    opponents[1].selected = true
 +
  elseif choice == 2 then
 +
    opponents[2].selected = true
 +
  elseif choice == 3 then
 +
    opponents[3].selected = true
 +
  elseif choice == 4 then
 +
    opponents[4].selected = true
 +
  elseif choice == 5 then
 +
    love.event.quit()
 +
  else
 +
    print("Invalid choice. Please try again.")
 +
  end
 +
end
 +
 
 +
function love.update(dt)
 +
  -- Display menu
 +
  displayMenu()
 +
end

Revision as of 18:42, 1 May 2024

local opponents = {

 {name = "Itadori", image = "characters/itadori.png", selected = false},
 {name = "Megumi", image = "characters/megumi.png", selected = false},
 {name = "Nobara", image = "characters/nobara.png", selected = false},
 {name = "Choso", image = "characters/choso.png", selected = false}

}

local player = {

 name = "Your Character",
 level = 1

}

local characterImages = {}

function love.load()

 for i, opponent in ipairs(opponents) do
   characterImages[i] = love.graphics.newImage(opponent.image)
 end

end

function drawCharacter(characterImage, x, y, scale)

 love.graphics.draw(characterImage, x, y, 0, scale, scale)

end

function love.draw()

 -- Draw the player character
 drawCharacter(characterImages[1], 50, 50, 1)
 -- Draw any opponent characters that have been selected
 for i, opponent in ipairs(opponents) do
   if opponent.selected then
     drawCharacter(characterImages[i], 300, 50 * i, 1)
   end
 end

end

function displayMenu()

 -- Print menu options
 for i, opponent in ipairs(opponents) do
   print(i .. ". Select " .. opponent.name)
 end
 print("5. Quit")
 -- Get user choice
 io.write("Enter your choice: ")
 local choice = io.read()
 choice = tonumber(choice)
 -- Perform actions based on choice
 if choice == 1 then
   opponents[1].selected = true
 elseif choice == 2 then
   opponents[2].selected = true
 elseif choice == 3 then
   opponents[3].selected = true
 elseif choice == 4 then
   opponents[4].selected = true
 elseif choice == 5 then
   love.event.quit()
 else
   print("Invalid choice. Please try again.")
 end

end

function love.update(dt)

 -- Display menu
 displayMenu()

end