forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with screen:blit...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Cybojanek



Joined: 16 May 2006
Posts: 1

PostPosted: Tue May 16, 2006 12:48 pm    Post subject: Help with screen:blit... Reply with quote

Hi,
I recenley started coding and I recieve an error when I run my code. ( on my PC). It states "Bad argument #2 to 'blit' <image expected, got table>
Here is my code. If you could pleases help me fix it I would be very grateful....
THNX :)

arrow = Image.load("arrow.png")
grass = Image.load("grass.png")

screenwidth = 480 - arrow:width()
screenheight = 272 - arrow:width()

arrow = {}
arrow[1] = { x = 200, y = 50}

--***** Main Loop *****
while true do
pad = Controls.read()
screen:clear()

for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end

screen:blit(300,220,arrow)

if pad:left() and arrow[1].x > 0 then
arrow[1].x = arrow[1].x - 2
end

if pad:right() and arrow[1].x < screenwidth then
arrow[1].x = arrow[1].x + 2
end

if pad:up() and arrow[1].y > 0 then
arrow[1].y = arrow[1].y - 2
end

if pad:down() and arrow[1].y < screenheight then
arrow[1].y = arrow[1].y + 2
end

screen.waitVblankStart()
screen.flip()
end
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Tue May 16, 2006 1:27 pm    Post subject: Reply with quote

Code:
arrow = Image.load("arrow.png")
grass = Image.load("grass.png")

screenwidth = 480 - arrow:width()
screenheight = 272 - arrow:width()

arrow = {}
arrow[1] = { x = 200, y = 50}
...
 

You had defined 'arrow' variable twice. The first definition was an image and the second was a table. That's why you got an error.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
Gary13579



Joined: 15 Aug 2005
Posts: 93

PostPosted: Tue May 16, 2006 1:31 pm    Post subject: Reply with quote

Ack, you beat me too it. I had my post done with color coding and everything :(
Back to top
View user's profile Send private message
daurnimator



Joined: 11 Dec 2005
Posts: 38
Location: melbourne, australia

PostPosted: Tue May 16, 2006 9:27 pm    Post subject: Reply with quote

your all too quick for me :S
Back to top
View user's profile Send private message MSN Messenger
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Tue May 16, 2006 11:29 pm    Post subject: Reply with quote

daurnimator wrote:
Ack, you beat me too it. I had my post done with color coding and everything :(

Why don't you just post your colorful reply, anyway? We all are curious to see yours.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
Gary13579



Joined: 15 Aug 2005
Posts: 93

PostPosted: Wed May 17, 2006 5:56 am    Post subject: Re: Help with screen:blit... Reply with quote

Quote:

arrow = Image.load("arrow.png")
grass = Image.load("grass.png")

screenwidth = 480 - arrow:width()
screenheight = 272 - arrow:width()

arrow = {}
arrow[1] = { x = 200, y = 50}

--***** Main Loop *****
while true do
pad = Controls.read()
screen:clear()

for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end

screen:blit(300,220,arrow)

if pad:left() and arrow[1].x > 0 then
arrow[1].x = arrow[1].x - 2
end

if pad:right() and arrow[1].x < screenwidth then
[color=red]arrow[1].x
= arrow[1].x + 2
end

if pad:up() and arrow[1].y > 0 then
arrow[1].y = arrow[1].y - 2
end

if pad:down() and arrow[1].y < screenheight then
arrow[1].y = arrow[1].y + 2
end

screen.waitVblankStart()
screen.flip()
end


Pretty much just replace the blue words with "arrowImg".

BTW, you screwed your quote tag up. It says daurnimator wrote that, when it was me..
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Wed May 17, 2006 6:28 am    Post subject: Reply with quote

Sorry, dude!

BTW, nice looking, indeed. :)
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group