PDA

View Full Version : Scene.lua (code help)



gunntims0103
November 12th, 2006, 22:35
well my main objective now is to implament a cut scene. iv been having one problem. I want to be able to press X and have the old talk sprite be cleared of the screen and have the next talk sprite be blit to the screen right after. I also want to be able to do this about 5 five time for different talk sprites. This is to give the effect of players talking

scene.lua


--load images, this is for the cutscene--
Background = Image.load("backgrounds/scene1.png")
Sora = Image.load("sprites/sora.png")
Enemie = Image.load("sprites/enemie.png")
Talk = Image.load("sprites/talk.png")
Talk2 = Image.load("sprites/talk2.png")
Talk3 = Image.load("sprites/talk3.png")
Talk4 = Image.load("sprites/talk4.png")
Talk5 = Image.load("sprites/talk5.png")

while true do
pad = Controls.read()
screen:clear()


--prints to screen--
screen:blit(0,0,Background,false)
screen:blit(31, 230,Sora)
screen:blit(330, 230,Enemie)
screen:blit(35, 30,Talk)

screen:waitVblankStart()
screen:flip()
end


help would be much appricaiated

thanx

gunntims0103
November 13th, 2006, 01:01
I was messing around with the code a little bit and got it to wear when i press X the talk sprite permenatly clears off the screen. Also i was able to all in the same function be able to blit the next talk sprite to the screen. I used this code


--controls to load new talk sprites--
if pad:cross() and not oldpad:cross then
Talk:clear()
screen:blit(35, 30,Talk2)
end

the only problem is that the next talk sprite only blits to the screen for a quick second then goes away how do i make it perminatly stay after you press and let go of X

thank you

--edit

This is what the new code looks like


--load images, this is for the cutscene--
Background = Image.load("backgrounds/scene1.png")
Sora = Image.load("sprites/sora.png")
Enemie = Image.load("sprites/enemie.png")
Talk = Image.load("sprites/talk.png")
Talk2 = Image.load("sprites/talk2.png")
Talk3 = Image.load("sprites/talk3.png")
Talk4 = Image.load("sprites/talk4.png")
Talk5 = Image.load("sprites/talk5.png")

current = 1

while true do

oldpad = pad
pad = Controls.read()
screen:clear()

--prints to screen--
screen:blit(0,0,Background,false)
screen:blit(31, 230,Sora)
screen:blit(330, 230,Enemie)
screen:blit(35, 30,Talk)

--controls to load new talk sprites--
if pad:cross() and not oldpad:cross() then
Talk:clear()
screen:blit(35, 30,Talk2)
end

screen:waitVblankStart()
screen:flip()
end


HOW DO I GET THE FREAKING SPRITE TO BLIT TO THE SCREEN PERMINATLY!!!

my brain hurts

--edit


ok iv read up on all the controls fuctions but i dont know how to implament these into my code to do what i want it to do

--this is what i found--

Controls

Controls Controls.read()

Bool controls:select()
Bool controls:start()
Bool controls:up()
Bool controls:right()
Bool controls:down()
Bool controls:left()
Bool controls:l()
Bool controls:r()
Bool controls:triangle()
Bool controls:circle()
Bool controls:cross()
Bool controls:square()
Bool controls:home()
Bool controls:hold()
Bool controls:note()

Number controls:analogX() -- ranges from -127 to 128.


Returns the current analog stick position in x direction.

Number controls:analogY() -- same


Returns the current analog stick position in y direction.

Bool (Controls a == Controls b) -- note! The analog stick is NOT considered when comparing because of analog fluctuations.


Compares two pad states.

Number controls:buttons() -- returns the bitmask like sceCtrlReadBufferPositive reads it


Constants for binary operations on buttons() result (for example “Controls.read():buttons() & Controls.startMask > 0” is the same as “Controls.read():start()”)

Number Controls.selectMask
Number Controls.startMask
Number Controls.upMask
Number Controls.rightMask
Number Controls.downMask
Number Controls.leftMask
Number Controls.ltriggerMask
Number Controls.rtriggerMask
Number Controls.triangleMask
Number Controls.circleMask
Number Controls.crossMask
Number Controls.squareMask
Number Controls.homeMask
Number Controls.holdMask
Number Controls.noteMask

--end of what i found--

gunntims0103
November 13th, 2006, 19:34
can no one help this is just sad :(. I just wanted to be able to press X and have the old talk sprite be cleared off the screen and have a new talk sprite be blit to the screen perminitly all in the same function. how do i do this. i used this code


--controls to load new talk sprites-- if pad:cross() and not oldpad:cross then Talk:clear() screen:blit(35, 30,Talk2) end

the only problem with this is that it doesnt blit the new image to the screen perminitly

please help

Zion
November 13th, 2006, 20:03
add screen.waitVblankStart() and screen.flip()

that will solve it :D

gunntims0103
November 13th, 2006, 21:42
add screen.waitVblankStart() and screen.flip()

that will solve it :D

no thats already inplace in the code the last code that i used above is the code that i used to clear the old talk sprite and blit a new one, but the only problem is that the new talk sprite is only bliting to the screen for a milisecond how do i make it blit perminitly after pressing X

heres the code



--load images, this is for the cutscene--
Background = Image.load("backgrounds/scene1.png")
Sora = Image.load("sprites/sora.png")
Enemie = Image.load("sprites/enemie.png")
Talk = Image.load("sprites/talk.png")
Talk2 = Image.load("sprites/talk2.png")
Talk3 = Image.load("sprites/talk3.png")
Talk4 = Image.load("sprites/talk4.png")
Talk5 = Image.load("sprites/talk5.png")

current = 1

while true do

oldpad = pad
pad = Controls.read()
screen:clear()

--prints to screen--
screen:blit(0,0,Background,false)
screen:blit(31, 230,Sora)
screen:blit(330, 230,Enemie)
screen:blit(35, 30,Talk)

--controls to load new talk sprites--
if pad:cross() and not oldpad:cross() then
Talk:clear()
screen:blit(35, 30,Talk2)
end

screen:waitVblankStart()
screen:flip()
end

Zion
November 13th, 2006, 22:04
try putting the screen.flip() before the vblank start. If you want, send me the file and il try and fix it for you

gunntims0103
November 14th, 2006, 03:31
o yea i finally got the first cut scene for sora adven out of the way. Thanx to ninja9393 for the super coding help. he was able to get the talk sprite cleared and blit a new one using dofiles. geez why didnt i think of that:D . Well anyways now that thats out the way im going to start coding the actual in game play which is gonna be my biggest mild stone.

S34MU5
November 14th, 2006, 09:46
Cool. Where did you get the sprites? what website? and what game they from. Plus will you need me to animate them or for bg's etc?

yaustar
November 14th, 2006, 14:39
The problem is here:

if pad:cross() and not oldpad:cross() then
Talk:clear()
screen:blit(35, 30,Talk2)
end
Talk2 is ONLY blitted if cross was pressed in this frame and not pressed last frame.

The blit needs to happen outside the if statement and the control of what image to blit needs to be in it.

Shadowblind
November 18th, 2006, 22:02
Well glad that barricade is out of the way :D