Log In  

Cart #the_upside-0 | 2019-07-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

cls()

print"mary jane's buster browns"

-- 0=using memcpy()
-- 1=using standard array
kind=1

if kind==0 then

memcpy(0,24576,320)
color(0)
rectfill(0,0,127,5)
color(7)
sspr(0,0,128,5,0,0,128,5,true,true)
reload(0,0,320)
sspr(0,0,8,8,0,0,8,8)
print("",0,24)
stop()

end

rev={}

for i=0,4 do
  rev[i]={}
  for j=0,127 do
    rev[i][j]=pget(j,i)
  end
end
for i=0,4 do
  for j=0,127 do
    pset(127-j,4-i,rev[i][j])
  end
end
rev=nil
spr(0,0)
print("",0,24)

What makes programming interesting is the many different ways in which you can approach a problem.

In this case, I wanted to be able to take a normal sentence and display it upside-down. Not mirrored, not inverted, but totally reversed.

There are 2 methods shown here on how to accomplish this each with their advantages and disadvantages.

I think the 1st method is a variation of some code I saw a year or so ago, so I can't claim credit to it - but I do understand how it works.

The 2nd method is brute force. Likely this method would work in any programming language, but likely also specifically for PICO-8 there is a better way to do it.

The red triangle shows that the sprite area is not corrupt (upon exit) as the first method uses this space for temporary storage of the image to be flipped upside - and the NIL is (hopefully) erasing the array that was temporarily used.

How about you ? Do you know of an easier way to code this effect ?

P#66231 2019-07-31 02:47 ( Edited 2019-07-31 02:59)


[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 14:10:36 | 0.010s | Q:14