you should download Notepad++
itll connect everything so you know which end to take out, and its very handy
Printable View
you should download Notepad++
itll connect everything so you know which end to take out, and its very handy
hi i have this error:
heres the chunk of code.Zitat:
error: index.lua:30: Argument error: Image:clear([color]) zero or one argument.
Code:if menunum == 1 then
screen.clear()
screen:blit(205, 147, StartOver)
screen:blit(229, 147, Quit)
end
if menunum == 2 then
screen.clear()
screen:blit(229, 147, QuitOver)
screen:blit(205, 147, Start)
try "screen:clear()"Zitat:
Zitat von hooger
clear() is an image function, not a function of the screen (like screen.flip())
Guys please can I have some help?
Currently my chracter walks off the screen. Heres my code:
Can someone edit that so it wont let the chracter off the screen? Cheers!Code:--Luigi Jump! Map 1
--Author: kozine
--Create colors
green=Color.new(0,255,0)
white = Color.new(255,255,255)
--Load image and draw map
floor = Image.load("images/floor.png")
background = Image.load("images/map1bg.png")
player1 = Image.load("images/luigistand.png")
Music.playFile("sounds/map1.it", true)
--Define Screen Width
screenwidth = 480 - player1:width()
screenheight = 272 - player1:height()
player = {}
player.gravity = 179
player.y = 179
player.x = 10
player.jumpspeed = 172
player.jumpstate = "ground"
--Begin Main Loop
while true do
pad = Controls.read()
screen:clear()
screen:blit(0, 0, background)
screen:blit(0, 208, floor)
if pad:left() then
player.x = player.x - 2
end
if pad:right() then
player.x = player.x + 2
end
if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping" end
if player.jumpstate == "jumping" then
player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end
if player.gravity < 0 then
player.jumpstate = "falling"
end
if player.gravity < 179 and player.jumpstate == "falling" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 179 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 179 then player.gravity = 179 end
player.y = player.gravity
screen:blit(player.x, player.y, player1)
screen.flip()
end
Ok my bad I tought it wouldn't work. I always use my version, besides it looks cleaner :razz: (trying to cover up my mistake :icon_wink )Zitat:
Zitat von c5cha7
@kozine:
add this somewhere before the screen.flip():
Code:if player.x<0 then
player.x=0
end
if player.x>480-player1:width() then
player.x=480-player1:width()
end
I wrote my first program, it's real simple, but the screen flashes and some of the text doesn't display at all. I think it's got something to do with screen.waitVblankStart() but I'm not sure.
Code:white = Color.new(255,255,255)
red = Color.new(255,0,0)
oldpad = Controls.read()
nickelsnd = Sound.load("game/nickel.wav")
dimesnd = Sound.load("game/dime.wav")
quartersnd = Sound.load("game/quarter.wav")
Music.volume(128)
screen:print(0,0,"Welcome to InvisibleSnake's RedBox",red)
--game loop
while true do
pad = Controls.read()
screen:print(100,100,"Press [] for a nickel",white)
screen.flip()
if pad:square() and oldpad:square() ~= pad:square() then
nickelsnd:play()
oldpad = pad
end
screen:print(100,150,"Press X for a dime",white)
screen.flip()
if pad:cross() and oldpad:cross() ~= pad:cross() then
dimesnd:play()
oldpad = pad
end
screen:print(100,200,"Press O for a quarter",white)
screen.flip()
if pad:circle() and oldpad:circle() ~= pad:circle() then
quartersnd:play()
oldpad = pad
end
screen.waitVblankStart()
screen.flip()
end
Thanks! It works :DZitat:
Zitat von Altair
Zitat:
Zitat von invisiblesnake
try this:
let me know if it works the way you want it to :D HTH!Code:white = Color.new(255,255,255)
red = Color.new(255,0,0)
nickelsnd = Sound.load("game/nickel.wav")
dimesnd = Sound.load("game/dime.wav")
quartersnd = Sound.load("game/quarter.wav")
Music.volume(128)
--game loop
while true do
pad = Controls.read()
screen:print(0,0,"Welcome to InvisibleSnake's RedBox",red)
screen:print(100,100,"Press [] for a nickel",white)
screen:print(100,150,"Press X for a dime",white)
screen:print(100,200,"Press O for a quarter",white)
if pad:square() and pad ~= oldpad then nickelsnd:play() end
if pad:cross() and pad ~= oldpad then dimesnd:play() end
if pad:circle() and pad ~= oldpad then quartersnd:play() end
oldpad = pad
screen.flip()
screen.waitVblankStart()
end
works like a charm, califrag, thank you
now it seems a little obvious i should've kept all the screen printing in the loop
thanks again!
Would it be hard to make an image fall from the top of the screen and then start walking around? Also can someone fix this code? Its beaten me. I get this error when trying to move backwards.
error: main.lua:91: bad argument #2 'blit' <Image expected, got nil>
Any help is appreaciated!Code:--Luigi Jump! Map 1
--Author: kozine
--Create colors
green=Color.new(0,255,0)
white = Color.new(255,255,255)
x = 10
y = 179
--Load image and draw map
floor = Image.load("images/floor.png")
background = Image.load("images/map1bg.png")
enemy1 = Image.load("images/enemy1.png")
leftlimit = 1
rightlimit = 440
uplimit = 1
downlimit = 230
Music.playFile("sounds/map1.it", true)
player = {}
player[1] = Image.load("luigi/luigi1.png")
player[2] = Image.load("luigi/luigi2.png")
player[3] = Image.load("luigi/luigi3.png")
player[4] = Image.load("luigi/luigi4.png")
player[5] = Image.load("luigi/luigi5.png")
player[6] = Image.load("luigi/luigi6.png")
player[7] = Image.load("luigi/luigi7.png")
player[8] = Image.load("luigi/luigi8.png")
player[9] = Image.load("luigi/luigi9.png")
player[10] = Image.load("luigi/luigi10.png")
playerimg=player[1]
anim = 1
animTimer = 0
animJump = 0
LastDirection = player[1]
Jumping=0
function jump()
if LastDirection==player[1] then playerimg=player[9]
elseif LastDirection==player[5] then playerimg=player[10]
end
animJump=animJump+1
if animJump>=1 and animJump<=4 then y=y-10
elseif animJump>=5 and animJump<=8 then y=y+10 end
if animJump>=9 then animJump=0 Jumping=0 end
end
function walkRight()
LastDirection=player[1]
animTimer=animTimer+1
if animTimer>=1 and animTimer<=4 then playerimg=player[2]
elseif animTimer>=5 and animTimer<=8 then playerimg=player[3]
end
if animTimer>=9 then animTimer=0 end
end
function walkLeft()
LastDirection=player[5]
animTimer=animTimer+1
if animTimer>=1 and animTimer<=4 then playerimg=player[6]
elseif animTimer>=5 and animTimer<=8 then playerimg=player[7]
end
if animTimer>=9 then animTimer=0 end
end
--Begin Main Loop
while true do
pad = Controls.read()
if pad:right() then walkRight() x=x+3 playerimg=playerimg
elseif pad:left() then walkLeft() x=x-3 playerimg=player1img
elseif pad:cross() then Jumping=1
else playerimg=LastDirection
end
if x<=leftlimit then x=leftlimit
elseif x>=rightlimit then x=rightlimit end
if y<=uplimit then y=uplimit
elseif y>=downlimit then y=downlimit end
if Jumping==1 then jump() end
if pad:start() then break end
screen:blit(0, 0, background)
screen:blit(0, 208, floor)
screen:blit(x, y, playerimg)
screen.flip()
end
invisiblesnake, if you want the "welcome..." only in the beginning of the game then put it outside the loop like you had, but put right after it:
So if you want it to show for 3 seconds: screen.waitVblankStart(18 0)Code:screen.waitVblankStart([amount of seconds times 60])
@kozine:
You have this:
So you are assigning playerimg to playerimg. This doesn't work. Also you already assigned the right pic in the function so you can just delete this.Code:--Begin Main Loop
while true do
pad = Controls.read()
if pad:right() then walkRight() x=x+3 playerimg=playerimg
elseif pad:left() then walkLeft() x=x-3 playerimg=player1img
etc.
Altair
So what should I put?
like i said; you can just delete it.
Ok you CAN leave it but its unnecesairy. Why it doesnt work is because the second is wrong. You have player1img instead of playerimg.
Cheers! It works now.
ofcourse :razz:
Ok well, it works on the windows lua player but not on the PSP :S It comes up with the file error!
What is the file error?
NVM. It was my own fault. Forget to include the main.lua file lol!
lol, i always do stuff like that kozine
I will need some help now but I'll post it on Youresam's bmplib post, so plz check that!
Thanks for all the help so far guys :D Next problem, I got the collision code snippet from the Developers Dungeon and have edited all the things that needed to be edited. Now the problem. There is no error or anything. Just that the to things font colide. Here is the code:
Code:--Luigi Jump! Map 1
--Author: kozine
--Create colors
green=Color.new(0,255,0)
white = Color.new(255,255,255)
x = 10
y = 179
w2 = 100
h2 = 22
x2 = 275
y2 = 125
x1 = 10
y1 = 179
w1 = 16
h1 = 35
--Load image and draw map
platform = Image.load("images/platform.png")
floor = Image.load("images/floor.png")
background = Image.load("images/map1bg.png")
pic = Image.load("images/enemy1.png")
picx=400
picy=179
leftlimit = 1
rightlimit = 470
uplimit = 1
downlimit = 230
Music.playFile("sounds/map1.it", true)
player = {}
player[1] = Image.load("luigi/luigi1.png")
player[2] = Image.load("luigi/luigi2.png")
player[3] = Image.load("luigi/luigi3.png")
player[4] = Image.load("luigi/luigi4.png")
player[5] = Image.load("luigi/luigi5.png")
player[6] = Image.load("luigi/luigi6.png")
player[7] = Image.load("luigi/luigi7.png")
player[8] = Image.load("luigi/luigi8.png")
player[9] = Image.load("luigi/luigi9.png")
player[10] = Image.load("luigi/luigi10.png")
playerimg=player[1]
anim = 1
animTimer = 0
animJump = 0
LastDirection = player[1]
Jumping=0
function collision(x1, y1, w1, h1, x2, y2, w2, h2)
if (y2 >= y1 and y1 + h1 >= y2)
or (y2 + h2 >= y1 and y1 + h1 >= y2 + h2)
or (y1 >= y2 and y2 + h2 >= y1)
or (y1 + h1 >= y2 and y2 + h2 >= y1 + h1)
then if x2 >= x1 and x1 + w1 >= x2 then return true
elseif x2 + w2 >= x1 and x1 + w1 >= x2 + w2 then return true
elseif x1 >= x2 and x2 + w2 >= x1 then return true
elseif x1 + w1 >= x2 and x2 + w2 >= x1 + w1
then return true
end
end
return false
end
function jump()
if LastDirection==player[1] then playerimg=player[9]
elseif LastDirection==player[5] then playerimg=player[10]
end
animJump=animJump+1
if animJump>=1 and animJump<=4 then y=y-30
elseif animJump>=5 and animJump<=8 then y=y+30 end
if animJump>=9 then animJump=0 Jumping=0 end
end
function walkRight()
LastDirection=player[1]
animTimer=animTimer+1
if animTimer>=1 and animTimer<=4 then playerimg=player[2]
elseif animTimer>=5 and animTimer<=8 then playerimg=player[3]
end
if animTimer>=9 then animTimer=0 end
end
function walkLeft()
LastDirection=player[5]
animTimer=animTimer+1
if animTimer>=1 and animTimer<=4 then playerimg=player[6]
elseif animTimer>=5 and animTimer<=8 then playerimg=player[7]
end
if animTimer>=9 then animTimer=0 end
end
--Begin Main Loop
while true do
pad = Controls.read()
if pad:right() then walkRight() x=x+3 playerimg=playerimg
elseif pad:left() then walkLeft() x=x-3 playerimg=playerimg
elseif pad:cross() then Jumping=1
else playerimg=LastDirection
end
if x<=leftlimit then x=leftlimit
elseif x>=rightlimit then x=rightlimit end
if y<=uplimit then y=uplimit
elseif y>=downlimit then y=downlimit end
if Jumping==1 then jump() end
if pad:start() then break end
screen:blit(0, 0, background)
screen:blit(0, 208, floor)
screen:blit(x, y, playerimg)
screen:blit(picx, picy, pic, 0, 0, pic:width(), pic:height())
if picy+pic:height()<208 then
picy=picy+10
end
if picy+pic:height()>208 then
picy=208-pic:height()
end
if picy +pic:height()==208 then
picx=picx-5
end
screen:blit(275, 125, platform)
screen.waitVblankStart()
screen.flip()
end
i can't help with that, I have a problem though. this is mainly for youresam to look at:
when i try and use bmp lib in my program it comes up with an error bmplib.lua: the file does not exist, and its in the same folder!!!!!!!!!!
Can anyone help, cheers, Glynnder
Post your code and if you and I are very lucky I may be able to help ;)
ok lol here it is:
I know i need a while true do in there somewhere. also i call this by saying dofile bmptga.luaCode:-- Lua Picture Converter v 0.01
-- created and designed by Glynnder
-- Please read the readme
-- Copyright Alex Glynn - PSPro
-- This is the bmp to tga converter
dofile("bmplib.lua") --load bmplib
screen:clear()
bmp = Image.bmpload("bmptest.bmp") --return the bmp as an image
screen:clear()
screen:blit(0,0,bmp) --blit the image
screen.flip()
pad = Controls.read()
if pad:cross() then
screen:save("images/convertedimage.tga")
end
if pad:start() then
dofile("script.lua")
end
if pad:select() then
break
end
I would say you need the dofile("bmplib.lua") in the main loop. Try that. With while true do
i tryed that, it didn't work
lemme try again
yep still goes "BMPLIB: No such file"
Its a pretty noobie question, but i forgot how to get a wav file to loop over and over, can anyone remind me plz?
EDIT: I didnt notice that i had 500 POSTS!!!
when you load it up write true in the parenthesis last, like sound=Sound.load("sound.w av", true) then it will keep looping when you play it.Zitat:
Zitat von Vaza
Bump :PC: :pZitat:
Zitat von kozine
haxor, got any idea's on my problem?
Umm..try this. You don't have a loop, and I definitely think you need one.
That should work, all the loaded stuff needs to be before the loop, all the command things need to be inside. If not post the error you get in windows lua and I will be able to help. Cheers on your app. :razz:Code:-- Lua Picture Converter v 0.01
-- created and designed by Glynnder
-- Please read the readme
-- Copyright Alex Glynn - PSPro
-- This is the bmp to tga converter
dofile("bmplib.lua") --load bmplib
bmp = Image.bmpload("bmptest.bmp") --return the bmp as an image
while true do
screen:clear()
screen:blit(0,0,bmp) --blit the image
screen.flip()
pad = Controls.read()
if pad:cross() then
screen:save("images/convertedimage.tga")
end
if pad:start() then
dofile("script.lua")
end
if pad:select() then
break
end
end
Can I have some help on my problem plz!
ok it worked with your code, but obviously loaded the test image, so i switched it to mine and it said must be 24 bit so I'll try converting it, thhanks very much for your help!
Sorry double post, but:
Thanks I converted it and it worked, smhame i g2g to be like now and then im @ skl tomorrow so sadly you'll probably have to wait till either thursday or next week cos if i dont get it done by thursday then we're racing till sunday!
Thanks wvery much and what do u mean cheers on ur app, r u saying it gd if so then THANKS!!!!!!!!!!!
I'll start working now
Yea, it means good job on working on this app.Zitat:
Zitat von Glynnder- PSPro
cool thanks, I know you will LOVE Codename: app 33, if you like this kind of stuff, it will take ages to release though. I might aim for it to be done on my bday (3rd Sept)
anyone?Zitat:
Zitat von Vaza
Hi Vaza, Friend 2 of 40,000 :D .Zitat:
Zitat von Vaza
I Am here to save the day!
to stop the music it is>Code:menu = Sound.load("Sounds/Menu.wav", true)
local sound=menu
voice = menu:play()
I hope that helps, and its better becauseCode:voice:stop()
it can actually stop the music from looping when you want it to.