Difference between revisions of "love.image"

m (Undo revision 29168 by Gojo (talk) (What was that?))
(Tag: Undo)
 
Line 1: Line 1:
local opponents = {
+
Provides an interface to decode encoded image data.
  {name = "Itadori", image = "characters/itadori.png", selected = false},
+
== Types ==
  {name = "Megumi", image = "characters/megumi.png", selected = false},
+
{{#ask: [[Category:Types]] [[parent::love.image]] [[Concept:Current]]
  {name = "Nobara", image = "characters/nobara.png", selected = false},
+
| headers=hide
  {name = "Choso", image = "characters/choso.png", selected = false}
+
| format=template
}
+
| 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}}
  
local player = {
+
== Other Languages ==
  name = "Your Character",
+
{{i18n|love.image}}
  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
 

Latest revision as of 20:52, 1 May 2024

Provides an interface to decode encoded image data.

Types

CompressedImageData Compressed image data designed to stay compressed in RAM and on the GPU. Added since 0.9.0
ImageData Raw (decoded) image data.

Functions

love.image.isCompressed Determines whether a file can be loaded as CompressedImageData. Added since 0.9.0
love.image.newCompressedData Create a new CompressedImageData object from a compressed image file. Added since 0.9.0
love.image.newEncodedImageData Encodes ImageData. Removed in 0.8.0
love.image.newImageData Creates a new ImageData object.

Enums

CompressedImageFormat Compressed image data formats. Added since 0.9.0
ImageEncodeFormat Image file formats supported by ImageData:encode.
PixelFormat Pixel formats for Textures, ImageData, and CompressedImageData. Added since 11.0

See Also


Other Languages