Advertising (This ad goes away for registered users. You can Login or Register)

[Lua][DevProR0]I need gif image help

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
dragonxtamer596
Posts: 188
Joined: Wed Oct 24, 2012 11:49 pm
Contact:

[Lua][DevProR0]I need gif image help

Post by dragonxtamer596 »

I need help with getting some gif images to work. What happens is they start but it doesn't get past the first image in the gif image set. I am using a lua interpreter by the name of DevPro R0.
Here is my code\/

Code: Select all

playerl=image.load("Images/leftidle.gif")
playerr=image.load("Images/rightidle.gif")
playeru=image.load("Images/upidle.gif")
playerd=image.load("Images/downidle.gif")
playerwl=image.load("Images/left.gif")
playerwr=image.load("Images/right.gif")
playerwu=image.load("Images/up.gif")
playerwd=image.load("Images/down.gif")
In the loop\/

Code: Select all

if direction == 1 then 
if not controls.left() then
  playerl.blit(Player.x,Player.y,playerl)
elseif controls.left() then
   playerwl.blit(Player.x,Player.y,playerwl)
end 
end 

if direction == 2 then 
if not controls.right() then
   playerr.blit(Player.x,Player.y,playerr)
elseif controls.right() then
   playerwr.blit(Player.x,Player.y,playerwr)
end
end 

if direction == 3 then 
if not controls.up() then
   playeru.blit(Player.x,Player.y,playeru)
elseif controls.up() then
   playerwu.blit(Player.x,Player.y,playerwu)
end
end 

if direction == 4 then 
if not controls.down() then
   playerd.blit(Player.x,Player.y,playerd)
elseif controls.down() then
   playerwd.blit(Player.x,Player.y,playerwd)
end
Whole thing\/

Code: Select all

green = color.new(0,128,0)
white = color.new(255,255,255)
brown = color.new(156,90,60)
black = color.new(0,0,0)
darkg = color.new(70,70,70)
lightg = color.new(180,180,180)
red = color.new(255,0,0)
blue = color.new(0,0,255)

mxhealth = 100 + mhealth

mxmana = 100 + mmana

background = image.create(480,272,green)

playerl=image.load("Images/leftidle.gif")
playerr=image.load("Images/rightidle.gif")
playeru=image.load("Images/upidle.gif")
playerd=image.load("Images/downidle.gif")
playerwl=image.load("Images/left.gif")
playerwr=image.load("Images/right.gif")
playerwu=image.load("Images/up.gif")
playerwd=image.load("Images/down.gif")

block1 = image.create(60,18,brown)

block2 = image.create(480,1,black)

block3 = image.create(1,272,black)

block4 = image.create(133,64,darkg)

block6 = image.create(60,64,darkg)

block5 = image.create(27,7,lightg)

block7 = image.create(27,7,lightg)

block8 = image.create(27,7,lightg)

block9 = image.create(27,7,lightg)

block10 = image.create(27,7,lightg)

Player = { x = 220 , y = 116}

playerHeight = 20
playerWidth = 20

function checkcontrols()
controls.read()
  
if controls.press("r") then 
screenpic("ms0:/PSP/PHOTO")
end

   

if controls.left() and controls.up() then
       Player.y = Player.y + 1.25
       Player.x = Player.x - 1.25
       direction = 1
       
   elseif controls.left() and controls.down() then
       Player.y = Player.y - 1.25
       Player.x = Player.x - 1.25
       direction = 1

   elseif controls.left() then
       Player.x = Player.x - 1.25
       direction = 1
     end  

if controls.right() and controls.down() then
       Player.y = Player.y - 1.25
       Player.x = Player.x + 1.25
       direction = 2

   elseif controls.right() and controls.up() then
       Player.y = Player.y + 1.25
       Player.x = Player.x + 1.25
       direction = 2

   elseif controls.right() then
       Player.x = Player.x + 1.25 
       direction = 2
     end

if controls.up() and controls.right() then
       Player.y = Player.y - 1.25
       Player.x = Player.x - 1.25
       direction = 3

   elseif controls.up() and controls.left() then
       Player.y = Player.y - 1.25
       Player.x = Player.x + 1.25
       direction = 3

   elseif controls.up() then
       Player.y = Player.y - 1.25
       direction = 3
     end

if controls.down() and controls.right() then
       Player.y = Player.y + 1.25
       Player.x = Player.x - 1.25
       direction = 4

   elseif controls.down() and controls.left() then
       Player.y = Player.y + 1.25
       Player.x = Player.x + 1.25
       direction = 4

   elseif controls.down() then
       Player.y = Player.y + 1.25
       direction = 4
     end

   if controls.press("start") then
       dofile("ingamemenu.lua")
     end
   if controls.press("select") then
       dofile("attributes.lua")
     end
end

Block1 = {}
Block1[1] = { x = 210, y = 0, height = block1:height(), width = block1:width() }

Block2 = {}
Block2[1] = { x = 0, y = 0, height = block2:height(), width = block2:width() }
Block2[2] = { x = 0, y = 271, height = block2:height(), width = block2:width() }

Block3 = {}
Block3[1] = { x = 0, y = 0, height = block3:height(), width = block3:width() }
Block3[2] = { x = 479, y = 0, height = block3:height(), width = block3:width() }

Block4 = {}
Block4[1] = { x = 45, y = 15, height = block4:height(), width = block4:width() }
Block4[2] = { x = 300, y = 15, height = block4:height(), width = block4:width() }
Block4[3] = { x = 45, y = 195, height = block4:height(), width = block4:width() }

Block6 = {}
Block6[1] = { x = 290, y = 195, height = block6:height(), width = block6:width() }
Block6[2] = { x = 370, y = 195, height = block6:height(), width = block6:width() }

Block5 = {}
Block5[1] = { x = 90, y = 79, height = block5:height(), width = block5:width() }

Block7 = {}
Block7[1] = { x = 355, y = 79, height = block7:height(), width = block7:width() }

Block8 = {}
Block8[1] = { x = 90, y = 188, height = block8:height(), width = block8:width() }

Block9 = {}
Block9[1] = { x = 307, y = 188, height = block9:height(), width = block9:width() }

Block10 = {}
Block10[1] = { x = 387, y = 188, height = block10:height(), width = block10:width() }


function collisionCheck1(block1)
   if (Player.x + playerWidth > block1.x) and (Player.x < block1.x + block1.width) and (Player.y + playerHeight > block1.y) and (Player.y < block1.y + block1.height) and (controls.press("cross")) then
  area = area + 1 
  dofile("enviroment.lua")
  end
end


function collisionCheck2(block2)
   if (Player.x + playerWidth > block2.x) and (Player.x < block2.x + block2.width) and (Player.y + playerHeight > block2.y) and (Player.y < block2.y + block2.height) then
    Player.x = oldx
    Player.y = oldy
  end
end


function collisionCheck3(block3)
   if (Player.x + playerWidth > block3.x) and (Player.x < block3.x + block3.width) and (Player.y + playerHeight > block3.y) and (Player.y < block3.y + block3.height) then
    Player.x = oldx
    Player.y = oldy
  end
end


function collisionCheck4(block4)
   if (Player.x + playerWidth > block4.x) and (Player.x < block4.x + block4.width) and (Player.y + playerHeight > block4.y) and (Player.y < block4.y + block4.height) then
    Player.x = oldx
    Player.y = oldy
  end
end

function collisionCheck6(block6)
   if (Player.x + playerWidth > block6.x) and (Player.x < block6.x + block6.width) and (Player.y + playerHeight > block6.y) and (Player.y < block6.y + block6.height) then
    Player.x = oldx
    Player.y = oldy
  end
end

function collisionCheck5(block5)
   if (Player.x + playerWidth > block5.x) and (Player.x < block5.x + block5.width) and (Player.y + playerHeight > block5.y) and (Player.y < block5.y + block5.height) and (controls.press("cross")) then
     dofile("shop.lua")
  end
end

function collisionCheck7(block7)
   if (Player.x + playerWidth > block7.x) and (Player.x < block7.x + block7.width) and (Player.y + playerHeight > block7.y) and (Player.y < block7.y + block7.height) and (controls.press("cross")) then
     dofile("shop1.lua")
  end
end

function collisionCheck8(block8)
   if (Player.x + playerWidth > block8.x) and (Player.x < block8.x + block8.width) and (Player.y + playerHeight > block8.y) and (Player.y < block8.y + block8.height) and (controls.press("cross")) then
     dofile("shop2.lua")
  end
end

function collisionCheck9(block5)
   if (Player.x + playerWidth > block5.x) and (Player.x < block5.x + block5.width) and (Player.y + playerHeight > block5.y) and (Player.y < block5.y + block5.height) then
   screen.print(5,260,"Item Shop",black)  
  end
end

function collisionCheck10(block7)
   if (Player.x + playerWidth > block7.x) and (Player.x < block7.x + block7.width) and (Player.y + playerHeight > block7.y) and (Player.y < block7.y + block7.height) then
   screen.print(5,260,"Weapon Shop",black)     
  end
end

function collisionCheck11(block8)
   if (Player.x + playerWidth > block8.x) and (Player.x < block8.x + block8.width) and (Player.y + playerHeight > block8.y) and (Player.y < block8.y + block8.height) then
   screen.print(5,260,"Armor Shop",black)     
  end
end

function collisionCheck12(block9)
   if (Player.x + playerWidth > block9.x) and (Player.x < block9.x + block9.width) and (Player.y + playerHeight > block9.y) and (Player.y < block9.y + block9.height) and (controls.press("cross")) then
     dofile("house.lua")     
  end
end

function collisionCheck13(block10)
   if (Player.x + playerWidth > block10.x) and (Player.x < block10.x + block10.width) and (Player.y + playerHeight > block10.y) and (Player.y < block10.y + block10.height) then
  screen.print(5,260,name.."'s home",black)
     if (controls.press("cross")) then 
     dofile("house1.lua")     
  end
end
end

while true do

   oldx = Player.x
   oldy = Player.y
   screen.clear()

   checkcontrols()

   collisionCheck1(Block1[1])

   collisionCheck2(Block2[1])
   collisionCheck2(Block2[2])

   collisionCheck3(Block3[1])
   collisionCheck3(Block3[2])

   collisionCheck4(Block4[1])
   collisionCheck4(Block4[2])
   collisionCheck4(Block4[3])

   collisionCheck5(Block5[1])

   collisionCheck6(Block6[1])
   collisionCheck6(Block6[2])

   collisionCheck7(Block7[1])

   collisionCheck8(Block8[1])

   collisionCheck12(Block9[1])

   collisionCheck13(Block10[1])

   background:blit(0,0)

   for a = 1,1 do
     block1:blit(Block1[a].x,Block1[a].y)
   end

   for a = 1,2 do
     block2:blit(Block2[a].x,Block2[a].y)
   end

   for a = 1,2 do
     block3:blit(Block3[a].x,Block3[a].y)
   end

   for a = 1,3 do
     block4:blit(Block4[a].x,Block4[a].y)
   end

   for a = 1,1 do
     block5:blit(Block5[a].x,Block5[a].y)
   end

   for a = 1,2 do
     block6:blit(Block6[a].x,Block6[a].y)
   end

   for a = 1,1 do
     block7:blit(Block7[a].x,Block7[a].y)
   end
   
   for a = 1,1 do
     block8:blit(Block8[a].x,Block8[a].y)
   end

   for a = 1,1 do
     block9:blit(Block9[a].x,Block9[a].y)
   end

   for a = 1,1 do
     block10:blit(Block10[a].x,Block10[a].y)
   end

   draw.fillrect(10,10,health/4,healthbar,red)

   screen.print(10,30,health,white)

   draw.fillrect(370,10,mana/4,manabar,blue)

   screen.print(370,30,mana,white)

   screen.print(Player.x-8,Player.y-10,name,.6,black,color.new(0,0,0,0))
  
if direction == 1 then 
if not controls.left() then
  playerl.blit(Player.x,Player.y,playerl)
elseif controls.left() then
   playerwl.blit(Player.x,Player.y,playerwl)
end 
end 

if direction == 2 then 
if not controls.right() then
   playerr.blit(Player.x,Player.y,playerr)
elseif controls.right() then
   playerwr.blit(Player.x,Player.y,playerwr)
end
end 

if direction == 3 then 
if not controls.up() then
   playeru.blit(Player.x,Player.y,playeru)
elseif controls.up() then
   playerwu.blit(Player.x,Player.y,playerwu)
end
end 

if direction == 4 then 
if not controls.down() then
   playerd.blit(Player.x,Player.y,playerd)
elseif controls.down() then
   playerwd.blit(Player.x,Player.y,playerwd)
end
end 

   collisionCheck9(Block5[1])

   collisionCheck10(Block7[1])

   collisionCheck11(Block8[1])

   screen.waitvblankstart()
   screen.flip()

   end 
Advertising
Post Reply

Return to “Programming and Security”