...Zitat:
Zitat von Urameshi
Luaplayer presumes PNG if the JPEG header is not found.
Printable View
...Zitat:
Zitat von Urameshi
Luaplayer presumes PNG if the JPEG header is not found.
crud, sorry line 33 is:
-= Double Post =-Zitat:
function ANIM:blit(x, y, delay)
just, wut do i need to change or put in animlib for it to work?
-= Double Post =-
cricket cricket, i think i made a noobish mistake
-= Double Post =-
ok, was my coding mistake THAT RETARDED?
Put all of the function
-- BLIT ANIMATION --
function ANIM:blit(x, y, delay)
self.interval = delay
self.timer:start()
if self.timer:time() >= self.interval then
self.currentFrame = self.currentFrame + 1
self.timer:reset()
end
if self.currentFrame > self.maxFrame then
self.currentFrame = 1
end
screen:blit(x, y, self.frame[self.currentFrame])
end
-= Double Post =-
ok, i fixed that, now, how would i state:
if pad:"nothing pressed"() then
...
end:Argh:
i tried bmplib, but when i start my app, it takes about 5 secs, while its doing dofile("bmplib.lua") ....Zitat:
Zitat von youresam
try:Zitat:
Zitat von moncristo_da_dev
if ~pad then
...code...
end
otherwise, you will have to do something like this:
if ~pad:cross() and ~pad:circle() and ~pad:square() and ~pad:triangle()...etc. then
...code...
end
Or you can create a AnyKey() function.
Pretty sure it's pad:buttons()==0, so ~pad:buttons() or (as Grimfate said) just ~pad should work.
0 is not false in lua. Any value other than false or nil is "true". And ~pad? Im pretty sure that wouldnt work, pad is a controls object, you cannot handlt it like you can in C.Zitat:
Zitat von LMelior
for lua, what image type files does it support?
and also, if there are any exceptions for the windows version, plz tell me
PNG and JPG, this info is available on lua players website
You can always edit the luaplayer source and add more libs for more image support. Isn't hard, just go to ps2dev.org and download their libs from svn in cygwin if you have it.
wut would be the code for the anykey function?Zitat:
Zitat von HaxxBlaster
if pad:buttons() > 0 then
is that the same as saying "if not pad:whatever then"
no.
It translates to "if there is more than 0 buttons being pressed then.."
awesome thinking yoursam, you really think outside the box
-= Double Post =-
is there an if statement that checks to see what the last pressed button was?
if oldpad:button() then
so that's wut oldpad stands for lol do you guys ever wonder wtf im making to be asking all these questions?
EDIT:if this is correct: pad = Controls.read()
would this be correct: oldpad = oldControls.read()
oldpad is set to pad at the begining of every loop so it holds the old value. you could name it fish for all it matters.
Something interesting
lolZitat:
Zitat von xpack
like i said
if this is correct: pad = Controls.read()
would this be correct: oldpad = oldControls.read()
cause i keep getting the error: attempt to index global 'oldpad' <a nil value>
no.
oldpad = pad
pad = Controls.read()
..you could make it
fish = pad
pad = Controls.read()
In other words, the "old" means nothing. Its just a variable.
so how would i make it read the wut the last button pressed was?
oldpad:button()
IE: oldpad:cross() checks to see if cross was pressed
ok thanx, i keep getting the message:error: attempt to index global 'oldpad' <a nil value>
Before the main loop put oldpad = Controls.read() and in the main loop put pad = Controls.read() oldpad = pad
ok, i got that to work, what i wanted to do is if left was pressed to load an image of the player facing left after the animation of it walking left was done and if right was pressed an image of the player facing right after the animation of the player walking right was done, but now when i press left or right, it doesn't show the animation of the player walking left or right now it just shows the image of the players facing whatever key you press and moving the same direction it's facing
-= Double Post =-
...:Argh: :confused:
Figure it out.
u know wut, im actually happy that someone is finally pushing me to actually do my own code thank you yorsam for pushing me to do it my self :spsp:
Em...yeah. Lua scripters not writing their own code is what is hurting the scene.
ok, i made my own code, but it just keeps play the animation for what ever button you press here is my code:
Code:dofile("animLib.lua")
standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
oldpad = Controls.read()
player = {}
player.x = 20
player.y = 210
player.img = standright
while true do
screen:clear()
pad = Controls.read()
oldpad = pad
if pad:right() then
player.img = runright
player.x = player.x + 7
end
if pad:left() then
player.img = runleft
player.x = player.x - 7
end
if pad:buttons() < 1 and oldpad:left() then
player.img = standleft
end
player.img:blit(player.x, player.y, 50)
screen.waitVblankStart()
screen.flip()
end
eww anim lib, cant help you there
...
...
*sigh*
Flip those. Youre also gonna have to mod it a bit for standleft.Code:player.img = standright
while true do
just look at the main loop
p.s. i made a sprite of the player image standing left or right with the same frame so it repeats and gives the illusion of an image
...........
it's not clearing the screen making player.img stand left if no buttons are pressed and if left was pressed
Code:dofile("animLib.lua")
standright = SS.new("jackstandright", "png", 24, 50, "images/jack/")
standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/")
runright = SS.new("jackrunright", "png", 64, 48, "images/jack/")
runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/")
oldpad = Controls.read()
player = {}
player.x = 20
player.y = 210
while true do
player.img = standright
screen:clear()
pad = Controls.read()
oldpad = pad
if pad:right() then
player.img = runright
player.x = player.x + 7
end
if pad:left() then
player.img = runleft
player.x = player.x - 7
end
if pad:buttons() < 1 and oldpad:left() then
screen:clear()
player.img = standleft
end
player.img:blit(player.x, player.y, 50)
screen.waitVblankStart()
screen.flip()
end
that's why i dont use animLib, too confusing
Why don't you just make a function to flip the image in lua and only need 1 image?
That would (if i didnt mess anything up) flip the image horizontally and be used like this:Code:function flip(img)
for i = 0, img:width() do
for j = 0, img:height() do
img:pixel(i,j,img:pixel(img:width()-i,img:height()-j))
end
end
return img
end
Code:someimage = Image.load("image.png")
someflippedimage = flip(someimage)
ya, but how would i get it to load a certain image after an animation is done, like if i press left, load playerleft or if i press right load imageright after an animation
if oldpad:right() and not pad:right() then
player.img = facingright
aka if right was pressed last loop but isnt this loop then make the playerimg facing right