WHy doesnt this work?
i want my enemy to walk across the screen.Code:screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
screen:blit(enemy.x,enemy.y,enemy1)
screen.flip()
Printable View
WHy doesnt this work?
i want my enemy to walk across the screen.Code:screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
screen:blit(enemy.x,enemy.y,enemy1)
screen.flip()
Cant tell you. I need to see more of your code. This part looks good, allthough i dont get why there are two "screen:blit(enemy.x,enem y .y,enemy1)", but that is probably because i dont see the rest of your code.
BTW People we're over the 1000 posts! WOOHOO!!!
Well i have this so far:
Code:--Colors
green=Color.new(0,255,0)
white=Color.new(255,255,255)
--Load Images
stand = Image.load("Images/stand.png")
jump = Image.load("Images/jump.png")
ground = Image.load("Images/ground.png")
background = Image.load("Images/background.png")
enemy1 = Image.load("Images/enemy.png")
--Variables
sprite = stand
num = 0
--Arrays
player = {}
player.gravity = 230
player.y = 230
player.x = 50
player.jumpspeed = 10
player.jumpstate = "ground"
enemy={x=480, y=244}
--Character Settings
function character()
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 < 230 and player.jumpstate == "falling" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 230 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 230 then player.gravity = 230 end
player.y = player.gravity
if player.jumpstate == "ground" then
sprite = stand
end
if player.jumpstate == "jumping" then
sprite = jump
end
screen:blit(player.x,player.y,sprite)
screen:blit(0,262,ground)
end
--Enemy 1 settings
function enemyset()
if enemy.x == 50 and player.jumpstate == "ground" then
screen:clear()
screen:print(240,136,"Game Over",green)
screen.waitVblankStart()
screen.flip()
end
screen:blit(enemy.x,enemy.y,enemy1)
end
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
--Take a screenshot
function screenshot()
if pad:select() then
screen:save("screenshot.png")
end
end
--Number
function number()
if pad:select() then
num = num + 1
end
end
--Main Loop
while true do
pad = Controls.read()
screen:blit(0,0,background,false)
character()
enemyset()
screen.waitVblankStart()
screen.flip()
screenshot()
number()
if pad:start() then
break
end
end
because its not in your enemyfunction (count the functions, if's and end's). So its not called upon. Change it to something like this:
Code:function enemyset()
if enemy.x == 50 and player.jumpstate == "ground" then
screen:clear()
screen:print(240,136,"Game Over",green)
screen.waitVblankStart()
screen.flip()
end
screen:blit(enemy.x,enemy .y,enemy1)
if enemy.x > 1 then
enemy.x = enemy.x - 10
end
end
Edit: Forget it.
Ahh sorted, my game is almost ready!
great!
Ok for ones i have a question:
Im blitting everything on an image and then i blit this image onto the screen. Now the thing thats going wrong is that the image isn't getting cleared so everything blits on top of eachother. Now the question is this: how do i make it so that it doesnt blit it on top of eachother, so how do i clear the image?
I tried clearing it and then blitting the stuff back, but clearing takes a long time when its a big image, so it goes really slow.
Also i tried putting the background image over it all, but i cant get that to work. What i do is this:
But map=level doesn't seem to work.Code:map=image.load('map.jpg')
level=map
whil true do
map=level
map:blit(....)
map:blit(....)
screen:blit(0,0,map,....)
etc.
end
I feel bad that i can't help after all the help you have given me. :cry:
Dont worry about it. As long as someone can and wants to help me :P
I finally finished the first version of my game, its not completely finished, and i need to tweak a few things, but i am going to continue updating this as much as i can, thanks for everyones help, especially Altair.
here it is:
http://forums.qj.net/psp-development-forum/43932-release-jumper-v1-0-a.html
quite a hard question to put a cross, but it's a simple answer.
i just want to know how often in lua the controls are read. so. for example. how long would the sound have to be (in seconds, or milliseconds) so the sound is not repeated over itself. so it just sounds like a continous sound without any loss of quality?
Can't you just put in so many vblanks?
for example a 10 second sound clip would be
screen.waitVblankStart(60 0)
I might be wrong
i'll give it a quick test. i'll let you know how it goes.
edit: i don't think it works. i can't see why it would be to do with the VblankStart, as i thought that was to do with the screen?
i'll show you how i did it.
[quoe]
if s == 1 then
if pad:down() and
oldpad:down() ~= pad:down() then
screen.waitVblankStart(60 0)
c:play()
end
end
[/quote]
the app loads up, but if you press the button it will just close.
why dont you just use a timer. So if the sound lasts 1 second. Make the timer count till 1 second. If the timer is one second then make it play the sound again.
(one thing that comes to mind is that if the loop isnt exactly a multiply of 1 second it still isn't correct, hmm)
Ok i kinda solved my problem (im sortof cheatin, cause i delete the part where it moves) but still it works and maybe better then how i wanted it. Still i would like to know how other people solved this problem.
i tried to add the timer, but to no avail. infact, i managed to break the entire script from putting it in. i couldn't find the error. if gave me line 232 as the error, but i swear there was nothing wrong with it! fair bit of extra work went into that script...oh well, i'll copy and paste out the good bits to a different one.
so back to the original question, anybody know how often the sound is repeated?
OK this isn't perticualirly a problem, but why do i need to have the code where I blit my images straight after the 'while true do'. I think this is why my menu isn't working. I'll try and post the code ASAP.
It'll post some clues to my next app and I may try it by incorporating it into PSysP Info
Post the code and i will try to help.Zitat:
Zitat von Glynnder- PSPro
If LUA says there is an error, then there is an error. Maybe not in that line self, but somewhere before that line. O well i already told you that i wasn't sure if it would work. Im sorry that it cost you alot of time. Ill try and find a better solution.Zitat:
i tried to add the timer, but to no avail. infact, i managed to break the entire script from putting it in. i couldn't find the error. if gave me line 232 as the error, but i swear there was nothing wrong with it! fair bit of extra work went into that script...oh well, i'll copy and paste out the good bits to a different one.
so back to the original question, anybody know how often the sound is repeated?
my break command works fine on windows, but not in PSP.
??? :icon_sad:
no worries altair, luckily, i just worked around the error. copied and pasted the stuff i had done into an older version of the app, so it works just fine! only took like 3 mins in the end.
i'll have to keep thinking on it i think. i will try out some sounds in lua and see they lose quality if i hold them down.
if you find it out, please tell me, since i have the same problem
Well. I'm preaty new to lua but have teh basics down. I want to make an rpg of some sort and right now I am trying to figure out how I would make the world (background?) from a tile sheet. I've seen some people do it that way so I figure its the best.
I have looked at a bunch of tuorials and came across: "http://wiki.ps2dev.org/psp:lua_player:tutorial" Which at the bottom tells me about tiles and how to use them.
now, I don't really get what is going on in the script. I could copy and past it and just use it but I would REALLY apriciate it if someone could tell me what each part means like:
"screen:blit(16 * x, 16 * y, tiles, 17 * tileX + 1, 17 * tileY + 1, 16, 16, false)"
screen:blit = prints picture to screen
16 * x = first cordinate of something something -- 16 = number of pixels of "image.png", *=multiply, x = bla bla bla...
or something like that. I dont know what Im talking about in the example but I hope you get what I mean. Thanks!
P.S. If this has been answered then Im really sorry. Its just that 103 pages is alot!
basically it's dynamically setting up the image locations and where they will appear on the screen..
imagine your PSP screen is like a cartoon animation.. you have different layers.. for example your background, main character, foreground, etc..
They all stack on top of each other in the order that you draw them.. so first things first you want to draw your background... in your case you will be using tiles to create the background.
A table is created to store the information for the background and where to draw each tile. A function would then read the information from the table and get the variables which tell lua where to put the image.
You should copy the tutorial script and images and get it working yourself. Once you have a working version of the tutorial, you can modify it by substituting your own images and adjusting the values to get it to work for your application. This will help you learn the small fine-tuning skills you will need to develop a bug-free application.
Hope I've helped answer your question and good luck!
I'm trying to blit a random image, i'm using this:
and my array looks like this:Code:screen:blit(enemy.x,enemy.y,enemysprite[math.random(1,2)])
But i get this error:Code:enemysprite = {}
enemysprite.a = Image.load("Images/enemy1.png")
enemysprite.b = Image.load("Images/enemy2.png")
Can you not blit from an array?Code:error: Jumper.lua:93: bad argument #2 to `blit' (Image expected, got nil)
Is there another way to do this?
hmm i think you can, but you can always just use variables. And say if var==1 then image1 end etc. But using a table would be more convenient ofcourse.
BTW what is the line where the error occurs?
The error occours on the blit.
Ok i got it: You haven't got it stored in enemysprite[number] but in enemysprite.a en .b which will never be generated by math.random obviously.
So what you should do is:
Code:enemysprite = {Image.load("Images/enemy1.png"),Image.load("Images/enemy2.png")}
can i ask some here??? guys if ever i update my psp to 2.6 version, can i still use my iso?
Well that is not the kind of question to ask here. This thread is for LUA help only.
But no you cannot use ISOs on 2.0+
--deleted
Yeah i saw it, thanks Altair.
Most of my problems seem to be stupid mistakes, but at least you put me right.
No prob and this way we get more games so i do it gladly.
Yeah more games!
As i start to get more experienced i will help here as much as i can.
Is it possible to make it so that a press only counts once each time?
For example, on my menu i have to tap left for one milisecond otherwise it zooms across, how can i make it so one press equals one move.
Is there anyway to blit an image, wait a set amount of time, then blit another?
err gutya, do something like:
oldpad = controls.read
pad = controls.read
if pad ~= oldpad then
code goes here...
oldpad = pad
end
At least i think its this
No, that does not work.