can u post the code for replacing the yellow pixels with purple?
Printable View
can u post the code for replacing the yellow pixels with purple?
heres my theory: i havent tried it yet.Zitat:
Zitat von Glynnder- PSPro
first, blit the image. THEN define purple, and yellow, and some vars:
then:(if the image is 480X272)Code:yellow = Color.new(255, 255, 0)
purple = Color.new(102, 0, 153)
a = 0
b = 0
probably wont work. but its worth a try.Code:while a < 481 and b < 273 do
color = image.pixel(a,b)
colors = color:colors()
if (color == yellow) then
assert(colors.r == 102)
assert(colors.g == 0)
assert(colors.b == 153)
a = a+1
else
a = a+1
end
if a > 480 then
a = 0
b = b+1
end
end
jw...
is there a way to break back to the xmb screen? i'm planning to make it a standalone app but i have an exit in there and i was wondering if there was a way to break back to the xmb screen?
edit: if i dl lua source do i need to re-compile it afterwards?
I asked this question a while back on a different forum. I never got an answer though.Zitat:
Zitat von slicer4ever
Also, does anybody know how to make gravity? Like if a player jumps, it comes back down.
kinda easy for example if you look at the source of my game(block attack you well see how i did gravity)
but heres an example:
that should work as to simulate sometype of gravityCode:cyan = Color.new(0,255,255)
block = Image.createEmpty(20,20)
block:clear(cyan)
gravity = 1
upmove = 5
block_Array = {}
block_Array[1] = {x = 240, y = 250}
function check_for_jump()
block_array[1].y = block_Array[1].y + gravity
if block_array[1].y > 250 then
block_array[1].y = 250
end
if pad:cross() then
block_Array[1].y = block_Array[1].y - upmove
end
end
while true do
screen:blit(block_array[1].x,block_array[1].y,block)
check_for_jump()
screen.flip()
screen.waitVblankStart()
end
Thanks, now that I really took a look at it, it's really easy.Zitat:
Zitat von slicer4ever
well since my other question hasen't been answered i ask a new one:
how do you draw a circle?
i've tried:
screen:drawcirc
screen:fillCirc
thats about it
From the lua code snippets thread :Zitat:
Zitat von slicer4ever
Plenty of other good snippets in there too.Code:function drawCirc(where, x, y, radius, color)
theta = 0
while theta<=360 do
where:drawLine((math.sin( theta)*radius)+x, (math.cos(theta)*radius)+ y, (math.sin(theta+1)*radius )+x, (math.cos(theta+1)*radius )+y, color)
theta = theta+1
end
end
o well i went to luaplayer.org and looked at ther functions thing ut couldn't find anything there well thanks=-)
edit: what am i surpose to put at the where?
How do you use animated sprites in lua?
Make a timer and for time 1-20 do one animation, 21-40 another animation, etc..
I thought of that, but I thought there would be an easier way.
ok i was wondering if someone could help me with this: so ok i have 2 blocks of the exact same size in which i want to touch and when they do i want them to change to another 2ndary picture i have for them so basicly i want a collision in which they touch a both change pictures because i can't figure it out so yeah thanks in advance
search "collisions in lua" and follow hat guide.Zitat:
Zitat von pspsalv2
i need help with making an object/picture move left and right because i what i seem to be doing is getting it to go only right and stop and not go back left so help[ would be much appreciated.
Can you post your code? Then its easier to help you. Or atleast the part which involves the moving of the character.
hey is there a way to get a character to move and change image while moving. What i mean by this is like when your using a sprite sheet.
Edit: i do actually know how to let the player move just not change images while doing so
The word you're looking for is 'animation'Zitat:
Zitat von mark.sparky
yes so do you know how to do it?
It's been too long since I used Lua to be of any assistance really.
What I would do though is download some of the hundreds of Lua homebrew games that are available and look at their animation code - it's the best way to learn.
thnx anyway even if you are no help
I remember seeing on the pspdev.org forums a example of animation. I believe is what on page 3, 4 or 5 of the lua section for psp. I'll try looking later if you are too lazy ;).
has anyone got TTLDE1.0 or 2.0 working with new Luaplayer20?? i used them fine on 0.16 but i keep getting a no script found in Luaplayer20...
http://www.sendspace.com/file/4jg6xl
Can someone take a look at my load. There is a problem with putting the animation on the screen.
okay i tried this:Zitat:
Can you post your code? Then its easier to help you. Or atleast the part which involves the moving of the character.
Today 11:11 AM
if x>= 0 and x < 450 then x = x + 2
end
if x == 450 and x>0 then x = x-2
end
but that just makes it stop at the right side forever so yeah please help
I think I may have had this problem before, try this:Zitat:
Zitat von pspsalv2
Hope this helps.Code:if x >= 0 and x <= 250 then
x=x+2
end
if x <= 450 and x >= 0 then
x = x - 2
end
EDIT- I just noticed why you get stuck on the right side. You put
if x == 450
that means that if x = 449 then it won't move left. Just change that to <=.
pspsalv2 - Thats because its doing what you told it to. I was kinda bored and had about 5-10 minutes so i made a visual :) You have a loop going on but you dont know it.
http://i42.photobucket.com/albums/e3...7mili/loop.jpg
Oh and as how to fix it, use a bool.
Your code still wont work as it applys to the above paradox. Plus, it doesnt matter if he says if it is == 450 as he is improving by 2's, so it WILL hit the 450 mark, then go down, then go back up for being less then 450.Zitat:
Zitat von Access_Denied
Zitat:
I think I may have had this problem before, try this:
Code:
if x >= 0 and x <= 250 then
x=x+2
end
if x <= 450 and x >= 0 then
x = x - 2
end
Hope this helps.
EDIT- I just noticed why you get stuck on the right side. You put
if x == 450
that means that if x = 449 then it won't move left. Just change that to <=.
thanks but access denied ....
yeah im not too sure what that is SG57 so if you or someone else could explain...pleaseZitat:
Oh and as how to fix it, use a bool.
Zitat:
Zitat von pspsalv2
a bool is basically a true or false statement. try this:
hiow i helpedCode:move_right = false
move_left = false
while true do
if if x >= 0 and x <= 250 then
move_right = true
move_left = false
end
if x <= 450 and x >= 0 then
move_right = false
move_left = true
end
if move_right == true then
x = x+2
end
if move_left == true then
x = x-2
end
end
Ok im assuming you understand SG57's explanation of why it moves to the right and then stops at 450.
About the boolean thing: a boolean is a variable that can either be "true" or "false".
So lets say you have a variable called "moveleft". While you move to the right, its false. When you are at 450 you set it to true. So you say:
if x == 450 then
moveleft=true
end
Then when its true you say:
if moveleft==true then
x=x-2
end
EDIT: Damn you Grimfate, grrrr!
lol, ive been damned many times before :pZitat:
Zitat von Altair
yeah i understand that i have it in a loop and a bool is very simple so thanks for your help Grimfate126, SG57, Access_Denied and Altair all of your help is greatly appreciated!
no prob. im bored anyway so ask if u have any more!Zitat:
Zitat von pspsalv2
I see now! I misread the code. At first I thought that you were doing this so that if you press left or right it moves left or right. But now I see you just want the image to move back and forth across the screen. I had problems with this before. What I did was make it so that if the images collided with a side, it would start moving. Something like:
This would make it so as soon as the loop start it start moving right. But when it hit the 450 mark it starts moving left. Then when it hits 0 it moves right again. It will keep moving until you put in a line that stops it.Code:function Bounce()
if image.x == 450 then
image.x = image.x - 2
end
if image.x == 0 then
image.x = image.x + 2
end
while true do
screen:blit(image you want to blit)
if image.x >0 and image.x < 450 then
image.x = image.x + 2
end
if image.x == 450 then
Bounce()
end
screen.waitVblankStart()
screen.flip()
end
I think I'm on the right track, but if I'm not, disregard everything I say. :)
EDIT: I spent so much time typing the code I didn't realize that someone already answered your question. Oh well.
hey here is the very basiz starting code for the startmenu of my game:the main thing is when i run it in lua player for windows all i see is a blank screen. Can you see any reason for thisCode:white = Color.new(255,255,255)
black = Color.new(0,0,0)
orange = Color.new(255,102,0)
menu = Image.load("startmenu.png")
screenwidth = 480
screenheight = 272
while true do
screen:clear()
screen:blit( 0, 0, menu, false)
screen:print(170,70,"Start",white)
screen.waitVblankStart()
screen.flip()
end
when u bilt the menu, dont put "false". try this:Zitat:
Zitat von mark.sparky
Code:white = Color.new(255,255,255)
black = Color.new(0,0,0)
orange = Color.new(255,102,0)
menu = Image.load("startmenu.png")
screenwidth = 480
screenheight = 272
while true do
screen:clear()
screen:blit( 0, 0, menu)
screen:print(170,70,"Start",white)
screen.waitVblankStart()
screen.flip()
end
no it didnt work it is still blank and the cmd now says:
Luaplayer's Mikmod has a critical error:
_mm_critical 1
_mm_ errno 15
None of the supported the sound-devices were detected
post your menu pic. what fromat is it?Zitat:
Zitat von mark.sparky
here is my menu (please dont use it anyone). http://i2.tinypic.com/1zyakcx.png. it is png
hmm, try it on your psp. it doesnt work for me either.Zitat:
Zitat von mark.sparky