hey sg57 how would i do that?...would be like
actually i have no clue, can you help me...il give u credit if you do, lol
Printable View
hey sg57 how would i do that?...would be like
actually i have no clue, can you help me...il give u credit if you do, lol
actually its a little harder than that, its currently slow because it loops through every pixel on the screen each frame, thats 130,560 pixels it has to deal with, per-frame.Zitat:
sounds like all he needs to do to speed it up is increase an integer somewhere
well thats what it used to do, he's changed it so it only loops through the section the text is in, witch is like one 20th of the screen (20x faster).
if u mean write, then probably not, i wanted to test it, but definetly can read from flash0/1Zitat:
Zitat von the undead
I've upgraded my pong code from ealier in this thread (if you saw it...).
Spoiler for My code:
But I'm getting this error:I think this means that you cant 'do math' on that variable, but all the other dummy variables in that function luaPlayers fine with.....Code:error: index.lua:47: attempt to perform local arithmatic on local 'w1' (a nil value)
Oh, and thanks to BlackShark whos code has been great to learn from! :tup: (Hope thats OK.... :o )
hehe, its cool, I just hope it helps ( and I see another great Pong game that rivals mine :D )
EDIT: the reason that comes up is because you have not defined w1 yet, w1 in this case would be the width of what ever object that applies to, weather ball or paddle. I don't think you defined the X's and Y's in there either, you'll probably get an error for those soon enough to if you don't define them!
Can someone help me? I've never gotten the error before, but when exiting my main game.lua file and reloading it, i get the error "Loop ingettable"
Any help please?
Thanks for your help BlackShark, but isnt the w1 variable a dummy var? (ie its only used in the function and arent defined, and whatever values are parsed through it through the function call change the variables.Zitat:
Zitat von BlackShark
eg.
That works and the variables arent declared, so why does mine not work?Code:white = Color.new(255,255,255)
function maths(x, y) -- dummy vars are x and y
return x * y -- these are not declared
end
while true do
num1 = 1
num2 = 2
test = maths(num1, num2)
screen:print(0,0, "The number is: " .. test, white)
screen.waitVblankStart()
screen.flip()
end
technecly,
Code:function maths(x, y) -- dummy vars are x and y
return x * y -- these are not declared
end
IS defining the x/y variables,
the w1 is supposed to be defined as the with of object 1 or maybe like your paddle, find the width of your paddle, then up in somewhere in your code write
w1 = 10
replace 10 with the actual width of your paddle.
even if i define it, i still get the same errorZitat:
Zitat von BlackShark
EDIT: Does a function accept table values as arguments?
Blake1 - The reason num1 and num2 arent giving you errors in your snippet, is becuase your setting them to a value, and that also means you'd be initlizing it, which means your creating it. Now, if you were comparing num1 and/or num2, than it would give you anerror as for one - there is no value in 'num1' and two, it cant find a variable named num1.
As for the motion blurr thing, yes, eyece explained it quite well. After seeing hte GIF, Im going to cut down on al ayer, so in turn that should boost it by 480*12 x faster. Think someone could test this:
Code:scene = {}
scene[1] = {newcolor = {r=0,g=0,b=0,a=0},
finalcolor = Color.new(0,0,0),
screencolor = Color.new(0,0,0),
image=Image.createEmpty(480,13)}
scene[2] = {newcolor = {r=0,g=0,b=0,a=0},
finalcolor = Color.new(0,0,0),
screencolor = Color.new(0,0,0),
image=Image.createEmpty(480,13)}
scene_num = 1
time = 0
pi = math.atan(1) * 4
i=0
y=0
x=0
screen:clear()
screen.waitVblankStart()
screen.flip()
while true do
for x=0,479 do
for y=130,142 do
scene[scene_num].screencolor = screen:pixel(x,y) -- get pixel color
scene[scene_num].newcolor = scene[scene_num].screencolor:colors() -- give it to new table
scene[scene_num].newcolor.a = 255/scene_num-40/scene_num -- edit transparency value
scene[scene_num].finalcolor = Color.new(scene[scene_num].newcolor.r,scene[scene_num].newcolor.g,scene[scene_num].newcolor.b,scene[scene_num].newcolor.a)
scene[scene_num].image:pixel(x,y-130,scene[scene_num].finalcolor) -- give that color to the old scene
end
end
scene_num = scene_num + 1
if scene_num > 2 then scene_num = 1 end
screen:clear()
x = math.sin(pi * 2 / 360 * time) * 150 + 180.5
screen:print(x, 131, "Does this blur?", Color.new(0,255,0))
time = time + 1
if time >= 360 then time = 0 end
for i=1,2 do screen:blit(0,130,scene[i].image) end
screen.waitVblankStart()
screen.flip()
end
im sure their is a wau to do it tho, or atleast i hope soZitat:
Zitat von myschoo
SG57 - the arguments that are going into the function are initialised, in an array/table .
Uh... what? The arguments in the function in your snippet are just place holders, in a sense. The best way to learn it, is to learn C's syntax, as it will help you understand programming in general much better.
That is your maths function in C. It returns a whole number (hence the 'int' data type), and hte arguments are being initilized, so no error there. Its just, when you call that function and supply the arguments with a value, than your setting those variables to those values, than running the code within the function...Code:int maths(int x, int y) { return x*y; }
I dont quite understand what you are saying, so please elaborate before i rant some more :Argh:Code:int some_vars[2];
some_var[0] = maths(3,9)
// whats happening here is...
maths ( x = 3, y = 9 ) { some_vars[0] = 3*9; }
some_var[1] = maths(2,13)
// whats happening here is...
maths ( x = 2, y = 13) { some_vars[1] = 2*13 }
its doing the same thing SG57, blurring, getting darker, and still showing that clip of the lowser (wtf).
I know their placeholders. They dont have to be defined outside of the function, right?
But the error im getting is:
with this code:Code:error: index.lua:47: attempt to perform local arithmatic on local 'w1' (a nil value)
Spoiler for My Code:But of couse the w1 var is a nil value, if its only a placeholder.Code:
EDIT: Why am I getting that empty code block in my post?
Blake, look at your third input argument the first time you use the collision function.
ya, you still haven't defined it, you need to, put "w1 = 10" or something like that above your function. you can change "10" to what ever the actual width of your paddle is.
any one know how to write to the flash(0 and 1) ive been looking all over the place
LMelior nailed it
Notice the typo? What the heck is ball[1].w?Code:if collision(ball[1].x, ball[1].y, ball[1].w, ball[1].img:height(), paddle[1].x, paddle[1].y, paddle[1].img:width(), paddle[1].img:height()) then
direction = "right"
end
Does anyone know how to make .xm files play smoothly?
I put in Music.playFile("moise.xm" , true) and it works, but it plays a note every second and lags my game like crazy.
then exchange true with false. and it will play once.
No, that wont make a difference. The problem is probably due to the psp running out of processing power, or the memory stick constantly being accessed. Try to optimise your code
theres no writing to flash 0/1 only read accessZitat:
Zitat von the undead
kthanks now i need to learn c and make a lua player mod, lolZitat:
Zitat von zmathue
know any good tuts?
-edit
actuallyy ill just learn c and make an eboot, so know any good tuts?...lol
Just have someone edit the LUA Player so we can get flash 0 write, But keep in mind LUA was meant for the beginning coders so thats why LUA is easy to learn.
if ever a mod was to come out like that, id make a mod flasher like xflash :), but who knows if that would ever be implemented.
I hope it doesn't happen, Too many newb LUA coders will start making stuff related to flash and i can see all the bricks already.
If you talking about my post (because I think you are) yes actually it will make a difference. Changing that last variable to false will play the song once or once everytime it is called. Trust me I made a app with a tuner in it.Zitat:
Zitat von PSPhakkor
Can someone help me? I have an error when using dofile() and then loading the same file again...Loop ingettable?
Need some code.