Log In  

In the following code, the sprite #17 is supposed to be visible during the first "wait(25)" after the collision. It worked in version 1.10C.

Since 1.11D the code sprite ball.spr=17 does not change the sprite after the collision. The sprite juste stay the same.

if ball then
if solid_a(ball, ball.dx, 0) then
if shield then
ball.frame=0
ball.spr=17
cls()
rectfill(0,0,128,128,0)
foreach(actor,draw_actor)
sfx(3)
wait(25)
del(actor,ball)
ball=nil
wait(25)

P#46230 2017-11-13 10:39 ( Edited 2017-11-14 14:27)

What is in your wait() function?

P#46255 2017-11-13 19:40 ( Edited 2017-11-14 00:40)

@Felice hey thanks for taking time to answer.
I kinda forgot that I did made that wait() function myself when I started to work on that game.
It's just a simple loop to waste some time.
Now I realize that it could just be that the loop is faster now in the new version and that we just don't see the sprite because it is too fast.
I'll look into that right now
thanks again for asking the right question !

here is the code:

function wait(w)
local i
local v
for i=1,w do
for t=0,30000 do
v=1
end
end
end

P#46256 2017-11-13 20:10 ( Edited 2017-11-14 01:10)

It's not the speed, I think the new version does not threat the following sequence of code the same way it did before:
cls()
rectfill(0,0,128,128,0)
foreach(actor,draw_actor)
sfx(3)
wait(25)

before 11c, the screen was rendered black by the cls() and because of the wait() we could see the black screen.

this code still render the screen black in 11c:
cls()
rectfill(0,0,128,128,0)
foreach(actor,draw_actor)
sfx(3)
fade(15,"out")

the waiting time is provided by the fade() function.
So for some reason, my wait() function does not do the job anymore :(
Here is the code of the fade() function:

function fade(t,io)
 -- palette fade

 local i
 local j
 local k
 local col

 if io == "in" then
  for i=t,0,-1 do
  for j=1,15,1 do
  --for j=15,1,-1 do
   col = j
   for k=1,((i+(j%5))/4) do
    col=dpal[col]
   end
   pal(j,col,1)
  end
  flip()
 end

 else
  for i=0,t do
  for j=1,15,1 do
  --for j=15,1,-1 do
   col = j
   for k=1,((i+(j%5))/4) do
    col=dpal[col]
   end
   pal(j,col,1)
  end
  flip()
 end
 end
end
P#46257 2017-11-13 20:49 ( Edited 2017-11-14 01:51)

Waiting for a certain amount of code to execute is not an ideal way to pass time in a game. You would be better waiting for a certain number of frames to pass.

As it happens, the way you wait a frame is to ask PICO-8 to display what you have drawn so far, using the flip() command. This will show what is currently drawn at the next vertical blank. Each time you call flip(), at least one frame will have passed since the last time you called it.

So, if you want to wait for one second, and if you're running 30fps (the default), you simply call flip() 30 times. This will solve both problems: cleaner code & displaying what you drew.

P#46279 2017-11-14 07:05 ( Edited 2017-11-14 12:05)

Wow ! thank you for that. I'll test that later today and let you know if it solve the problem. Thanks !!

P#46280 2017-11-14 07:47 ( Edited 2017-11-14 12:47)

I works !! thank you very much @Felice

P#46284 2017-11-14 09:27 ( Edited 2017-11-14 14:27)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 12:23:23 | 0.010s | Q:18