I will checkup on that...I think I saw some code somehwere for that involving 'break".Zitat:
Zitat von Gutya
Printable View
I will checkup on that...I think I saw some code somehwere for that involving 'break".Zitat:
Zitat von Gutya
Ok cheers.
break just quits a loop. The way to exit a file is to have all the code ran as far as I know.
It works if i put it in the main loop, but it won't allow me to put it in a function.
--Loop in gettable. Help?Code:screen:blit(stick.x, stick.y, stick)
ok what is wrong with this? everything flickers....
and two, how do I make it so you only have to press X once for the animation to keep going, not hold it down?Code:if pad:cross()and status == 0 then
x = math.sin(pi * 2 / 360 * time) * 150 + 192.5
screen:blit(0, 0, s11)
time = time + 1
if time >= 180 then
screen:blit(0, 0, s12)
end
if time >= 360 then
time = 0
end
screen.waitVblankStart()
screen.flip()
end
EDIT: I just realized that this is not the kind of code that I want. I want the animation to stay stationary. I am very confused.....
So.. where can I learn about simple collision? In my game I'm not going to have any action or shooting or such, just need it to do something when I walk up to someone and press X.
ok i have a stationary animation code but it is not workign the way i want it to. I want it to last longer and it also, when it switches, doesnt go as far over as i want it. how do i do that?
Code:if pad:cross()and status == 0 then
-- current player position
playerX = 10
playerY = 10
-- blit current player animation image
screen:blit((playerX - 1) * 16 - 4, (playerY - 1) * 16 - 4, s1pic, 1 + 25 *
animation, 1, 156, 80)
-- calculate next animation image
animationSlowDown = animationSlowDown + 1
if animationSlowDown == 2 then
animationSlowDown = 0
animation = animation + animationDirection
if animation == 2 then
animationDirection = -1
elseif animation == 0 then
animationDirection = 1
end
end
Im having some trouble with my game...it's not displaying the right sprite. Please PM me if you can help.
Check AIM man, I fixed it already!Zitat:
Zitat von TheMarioKarters
I have not seen a tutorial about simple collision yet...Zitat:
Zitat von Spiritbeast
I might make one...
Yea please do. I need to learn collision.
i would appreciate a collision guide too,,
i think i have some idea how its done, but theres probably an easier way then what im thinking,,
so it would help out
If i get a bit of time tommorow ill look into it.
i was thinking it might work like (well for my game)Code:if stick.x == spike.x then
screen:clear()
screen:blit(0,0,death,false)
when ever i try to put a timer function i ALWAYS get this error
attempt to index global 'Timer' (a nil value)
on that line i have this
timer = Timer.new()
what am i missing?
EDIT nvm,, it seems the eboot i was using didnt allow that function
that would be nice:DZitat:
Zitat von Sousanator
For collision, as long as you specify the part of the thing which is colliding, and with what other object, it should be ok.
So if you specify an area of a character, then tell it if something lands in the same place, make it do the thing you want.
Don't know if it helps, it probably doesn't...
I added a screen:print with a font and now i get no script file found...
Sned me a PM to remind me (I often forget) and I will sned you an example of how to print fonts and load them correctly with mono spacing and everyhting. I have a good one.Zitat:
Zitat von Gutya
Ok. Done.
I need a code:
pic A, pic B
pic A is loaded on the screen, when I press X pic A disappears and pic B appears. As long as I have the x button pressed pic B shows not pic A. When I let go of X pic B disappears and pic A appears again.
It sounds easy but I cant get it working.Thanks in advance and sorry for a stupid request.
Ok try this:
That works for me!Code:--Load images
pica = Image.load("Path to image")
picb = Image.load("Path to image")
--Begin the main loop
while true do
pad = Controls.read()
screen:blit(0, 0, pica)
if pad:cross() then
screen:blit(0, 0, picb)
end
screen.flip()
end
ok, how do I make this animation go slower?
you can change the CPU speed and max frame skip
sorry i forgot to post it... here
Code:if pad:cross()and status == 0 then
-- current player position
playerX = 10
playerY = 10
-- blit current player animation image
screen:blit((playerX - 1) * 16 - 4, (playerY - 1) * 16 - 4, s1pic, 1 + 80 *
animation, 1, 78, 80)
-- calculate next animation image
animationSlowDown = animationSlowDown + 1
if animationSlowDown == 2 then
animationSlowDown = 0
animation = animation + animationDirection
if animation == 2 then
animationDirection = -1
elseif animation == 0 then
animationDirection = 1
end
end
how do i slow that down?
Thanks I'll try it.Zitat:
Zitat von kozine
Can someone help me? Im trying to have a character move when I press right, here is what I have so far. Note: The "loading finished" does not disappear after 4 seconds, the character image blinks (probably due to the fact the image is not transparent) and the character does nothing when I press right. Can someone tell me whats wrong? Thanks in advance.
white = Color.new(255, 255, 255)
char = Image.load("char.png")
y = 100
screen:print(100, 100, "loading finished", white)
screen.flip()
screen.waitVblankStart(24 0)
screen:clear()
screen:blit(150, y, char)
screen.flip()
pad = Controls.read()
if pad:right() then
y = y + 5
end
while true do
screen.waitVblankStart()
screen.flip()
end
You need to have your pad stuff inside your while loop. Like this:
white = Color.new(255, 255, 255)
char = Image.load("char.png")
y = 100
screenrint(100, 100, "loading finished", white)
screen.flip()
screen.waitVblankStart(24 0)
screen:clear()
while true do
pad = Controls.read()
if pad:right() then
y = y + 5
end
screen:blit(150, y, char)
screen.flip()
screen.waitVblankStart()
screen.flip()
end
Why are you having the vertical value increase when you press right? You should be increasing the x value
yea - but you can still use the letter y althugh it gets confusign, you just have to say (y, 100, ....)
but i would use X
TO - I really think people should use the devs one more, then we will be asking harder q's eh?
Ya, but Im just saying its just easier to put (x, 25, ...) and then have x = x +5 when you press right
ya I know, hey TO, what are you currently working on?
Check the sig....im about to get back to work on Tux Rampage, as I have a backup of that project, so I can continue where I left off
could someone help me every time I load my lua thingy it gets to loading 90% but then my psp takes me back to eloader screen someone help me heres my code:
Code:pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 153, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
screen:print(194, 136, "Loading: 0%", pink)
screen.flip()
background = Image.load("images/background.jpg")
screen:clear()
screen:print(194, 136, "Loading: 20%", pink)
screen.flip()
circle = Image.load("images/buttons/circle_button.png")
down = Image.load("images/buttons/down_arrow.png")
screen:clear()
screen:print(194, 136, "Loading: 40%", pink)
screen.flip()
l = Image.load("images/buttons/left_trigger.png")
left = Image.load("images/buttons/left_arrow.png")
screen:clear()
screen:print(194, 136, "Loading: 60%", pink)
screen.flip()
r = Image.load("images/buttons/right_trigger.png")
right = Image.load("images/buttons/right_arrow.png")
boltsnd = Sound.load("music/comp.wav")
screen:clear()
screen:print(194, 136, "Loading: 80%", pink)
screen.flip()
square = Image.load("images/buttons/square_button.png")
triangle = Image.load("images/buttons/triangle_button.png")
screen:clear()
screen:print(194, 136, "Loading: 90%", pink)
screen.flip()
up = Image.load("images/buttons/up_arrow.png")
x = Image.load("images/buttons/cross_button.png")
splash = Image.load("images/lua.gif")
screen:clear()
screen:print(194, 136, "Loading: 100%", pink)
screen.flip()
screen.waitVblankStart(60)
screen:blit(0, 0, splash, false)
screen.waitVblankStart()
screen.flip()
boltsnd:play()
screen.waitVblankStart(240)
Music.volume(128)
while true do
screen:blit(0, 0, background, false)
pad = Controls.read()
screen:print(135, 251, "Press 'Start' to restart", blue)
screen:print(110, 261, "Press 'Select' for a screenshot", blue)
screen:print(383, 35, "Support:", black)
screen:print(365, 45, "PS3Lounge.net", orange)
screen:print(365, 55, "scriptscribbler.com/psp", gray)
screen.flip()
if pad:cross() then
screen:blit(50, 228, x)
screen.flip()
end
if pad:circle() then
screen:blit(90, 195, circle)
screen.flip()
end
if pad:triangle() then
screen:blit(45, 165, triangle)
screen.flip()
end
if pad:square() then
screen:blit(15, 195, square)
screen.flip()
end
if pad:up() then
screen:blit(60, 40, up)
screen.flip()
end
if pad:right() then
screen:blit(90, 65, right)
screen.flip()
end
if pad:down() then
screen:blit(60, 80, down)
screen.flip()
end
if pad:left() then
screen:blit(30, 65, left)
screen.flip()
end
if pad:l() then
screen:blit(4, 6, l)
screen.flip()
end
if pad:r() then
screen:blit(403, 4, r)
screen.flip()
end
if pad:select() then screen:save("screenshot.tga") end
if pad:start() then
break
end
end
Try this:
Code:pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 153, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
background = Image.load("images/background.jpg")
circle = Image.load("images/buttons/circle_button.png")
down = Image.load("images/buttons/down_arrow.png")
l = Image.load("images/buttons/left_trigger.png")
left = Image.load("images/buttons/left_arrow.png")
r = Image.load("images/buttons/right_trigger.png")
right = Image.load("images/buttons/right_arrow.png")
square = Image.load("images/buttons/square_button.png")
triangle = Image.load("images/buttons/triangle_button.png")
up = Image.load("images/buttons/up_arrow.png")
x = Image.load("images/buttons/cross_button.png")
splash = Image.load("images/lua.gif")
boltsnd = Sound.load("music/comp.wav")
screen:print(194, 136, "Loading: 0%", pink)
screen.flip()
screen:clear()
screen:print(194, 136, "Loading: 20%", pink)
screen.flip()
screen:clear()
screen:print(194, 136, "Loading: 40%", pink)
screen.flip()
screen:clear()
screen:print(194, 136, "Loading: 60%", pink)
screen.flip()
screen:clear()
screen:print(194, 136, "Loading: 80%", pink)
screen.flip()
screen:clear()
screen:print(194, 136, "Loading: 90%", pink)
screen.flip()
screen:clear()
screen:print(194, 136, "Loading: 100%", pink)
screen.flip()
screen.waitVblankStart(60 )
screen:blit(0, 0, splash, false)
screen.waitVblankStart()
screen.flip()
boltsnd:play()
screen.waitVblankStart(24 0)
Music.volume(128)
while true do
screen:blit(0, 0, background, false)
pad = Controls.read()
screen:print(135, 251, "Press 'Start' to restart", blue)
screen:print(110, 261, "Press 'Select' for a screenshot", blue)
screen:print(383, 35, "Support:", black)
screen:print(365, 45, "PS3Lounge.net", orange)
screen:print(365, 55, "scriptscribbler.com/psp", gray)
screen.flip()
if pad:cross() then
screen:blit(50, 228, x)
screen.flip()
end
if pad:circle() then
screen:blit(90, 195, circle)
screen.flip()
end
if pad:triangle() then
screen:blit(45, 165, triangle)
screen.flip()
end
if pad:square() then
screen:blit(15, 195, square)
screen.flip()
end
if pad:up() then
screen:blit(60, 40, up)
screen.flip()
end
if pad:right() then
screen:blit(90, 65, right)
screen.flip()
end
if pad:down() then
screen:blit(60, 80, down)
screen.flip()
end
if pad:left() then
screen:blit(30, 65, left)
screen.flip()
end
if pad:l() then
screen:blit(4, 6, l)
screen.flip()
end
if pad:r() then
screen:blit(403, 4, r)
screen.flip()
end
if pad:select() then screen:save("screenshot.tga") end
if pad:start() then
break
end
end
How big can your .wav files be? Because I'm trying to use some for music but just by going song:play() (song is my song variable).
i think they can be as big as you want them to be. try it. i am not too sure. if not, edit it down a bit
I am so stuck on these tile backgrounds. Its really annoying me also.
Error:Code:--Load images
tiles = Image.load("images/specialtiles.png")
-- the map
map1 = {
"dkkkkkkkkfaaaaaaaaaaaaaaa",
"ibgbgbbgbjaaaaaaaaaaaaaaa",
"ibgbgbbgbjaaaaaaaaaaaaaaa",
"ibgbgbbgbjaaaaaaaaaaaaaaa",
"ibgbgbbgbjaaaaaaaaaaaaaaa",
"ibgbgbbgbjaaaaaaaaaaaaaaa",
"hlllllllleaaaaaaaacpaaaaa",
"aaaaaaaaaaaaaaaaaanoaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaaaaaaa"
}
function drawTile(tile, x, y)
local tileX = math.mod(tile, 4)
local tileY = math.floor(tile / 4)
screen:blit(16 * x, 16 * y, tiles, 17 * tileX + 1, 17 * tileY + 1, 16, 16, false)
end
while true do
for y = 1, 17 do
line = map1[y]
for x = 1, 30 do
tile = string.byte(line, x) - string.byte("a")
drawTile(tile, x - 1, y - 1)
end
end
screen.flip()
end
error: game.lua:40: attempt to perform arithmetic on a nil value
Please help!