Follow
Peej
 1
[ :: Read More :: ]

Hello all.
I'm probably missing something really important but I'm trying to put a gradient sky on my game.
I spotted some code I thought would do the trick in another thread.

 ```poke(0x5f5f,0x3c) -- 0x3c is the colour of the blue sky to be replaced. pal({[0]=0x82,0x82,0x84,0x84,4,4,0x89,0x89,0x8e,0x8e,0x8f,0x8f,15,15,0x87,0x87},2) memset(0x5f70,0xaa,16)```

It's supposed to do a sunset gradient-styled sky, but I only get this:

Editing the colours in the table result in the same!

Ideally, I'd like it different shades of blue as in the other example, but I'll cross that bridge later.

P#133412 2023-08-22 20:47 ( Edited 2023-08-22 21:51)

[ :: Read More :: ]

Hello all...
I've been looking up how to have leading 0s on my score displayed on screen.
Some of the explanations I've seen look very complicated.

How difficult is it to have, say 00050 rather than just 50 displayed as the player score.

Thanks

Peej

P#100301 2021-11-17 22:35

[ :: Read More :: ]

Hello again.
Following on from the other topic where I ask what I've done wrong to break my Pico-8 install....
I have this code that does a circle fill cross fade:

 ```function invcircfill(r,c) local r2=r*r color(c) for j=0,127 do local y=64-j local x=sqrt(max(r2-y*y)) rectfill(0,j,64-x,j) rectfill(64+x,j,127,j) end end```

In the DRAW function I have this, that I also pilfered:

 `invcircfill(90*abs(cos(time()/4)),0)`

The above bit obviously calls the function but I'm not sure how it works.
It bounces in and out on a loop.

Would someone WAY more advance than I, please explain what I should have instead of that call to make the circle either expand once or contract one.

Thanks again

Peej

P#99657 2021-11-06 00:17

[ :: Read More :: ]

Hello all.
I have a problem suddenly with Visual Studio Code and I hope I've not broken something.

I found a nice bit of code on the BBS that did a circular cross fade and copied it over to my project.

When I run it through Visual Studio Code it says "WARNING NO PERMANENT STORAGE"

Then the game runs.

Does anyone know what I've done wrong??

I just hope it's not going to stop saving or just go ca-ca after so much work being put into it.

P#99656 2021-11-05 23:59

[ :: Read More :: ]

Hi guys:
This is kinda embarrassing but I'm not 100% sure how ELSE works.

If an if condition is originally TRUE, does the ELSE say "Well I'll do this is it's FALSE"?

c="ORANGE"
IF c="ORANGE" then print "YES" (This is definitely true)
ELSE print "NO" (Somewhere in the code, c changes to APPLE)

c="ORANGE"
IF c="PLUM" OR c="GRAPE" then then print "YES"
ELSE print "NO" (It does this line because c is NEITHER PLUM or GRAPE)

I think that's correct so far. But I get a bit stuck on ELSEIF

c="ORANGE" b="APPLE"
IF c="PLUM" OR c="GRAPE" then then print "YES"
ELSEIF b="APPLE" print "THIS LINE!"

Does the psudo code above confirm the fact that c is NOT PLUM or GRAPE but sees that b is APPLE so runs that and prints "THIS LINE!"

It's hard to explain why I get stuck. I hope someone gets what I'm trying to ask.

Cheers

P#98603 2021-10-13 22:07

[ :: Read More :: ]

Hello all.
Can any of you clever folk make this code shorter?
It's bugging the life out of me but I don't know how to make it shorter though it looks like it can be.
Cheers.

 ``` --p.c= n / 2 + 0.5 ? if (p.t/p.die<7/#p.c_table) p.c=4 if (p.t/p.die<5/#p.c_table) p.c=3 if (p.t/p.die<3/#p.c_table) p.c=2 if (p.t/p.die<1/#p.c_table) p.c=1```
P#98516 2021-10-11 18:13

[ :: Read More :: ]

Hi guys.
I just thought I'd share what I have achieved so far.
Not much, I know, but it's slow progress.

Arrows, left and right to run.
Z to double jump/stomp on ground.
X to jump

I'm not overly happy with the bounce about that the bad guys to when they get ground stomped.
Sometimes they bounce too high and long, other times, hardly at all.
I have no idea how to fix that!

The spider, finding the highest level through a gap, I'm quite pleased with.

Have a looky, see what you think.

Cheers

Cart #zukizuzomi-4 | 2021-09-30 | Code ▽ | No License

P#98064 2021-09-30 20:58

 1
[ :: Read More :: ]

Hi guys.
I have an enemy that moves towards the player.
I have the usual set up with DX, DY, X, Y. Where X and Y are the co-ordinates of enemy, DX & DY are the direction of movement.
I thought it would be good to have it set up like this:

e.dx and e.dy are the enemies dx and dy.
e.x and e.y are the enemies x and y cords.

plyr.x and plyr.y are the players co-ords...

If the plyr.x MINUS the enemy.x is a positive sign in the result, move the dx 1 or right.
If the plyr.x MINUS the enemy.x is a negative sign in the result, move the dx negative 1 or left.

If the plyr.y, minus 2 (so the enemy is slightly higher) MINUS the enemy.y is a positive sign in the result, move the dy 1 or down.
If the plyr.y, minus 2 (so the enemy is slightly higher) MINUS the enemy.y is a negative sign in the result, move the dy -1 or up.

 ```e.dx=sgn(plyr.x-e.x) e.dy=sgn((plyr.y-2)-e.y)```

This works very well and I was pleased with myself for shortening the code.

However, my problem is (especially on the y) that if the enemy and the player are the same y value, the enemy wiggles up and down and the sign of the maths goes -1,1,-1,1,-1,1,-1 etc...

I seem to remember there's something I'm missing to stop the enemy 'vibrating' like this when the coodinates are the same but can't remember what it is.

Cheers.

P#97940 2021-09-28 22:25

 3
[ :: Read More :: ]

Hello all...

1/ Can someone explain how to do a particle explosion thing that emits in a circular pattern?
I've experimented with particles for dust etc. but thought it might be nice to have a pickup emit a circular particle system when picked up. I don't know how to work with the x and y for each particle.

2/ Can someone point me to a tutorial or code, or whatever for those old school passcode systems for level/life/score saves. I wanted to have a system in their as a homage to games gone by that one would type in a 5 digit passcode and it would carry on the game where you left off. Like Bubble Bobble used to have.

Peej

P#97018 2021-09-07 20:19

[ :: Read More :: ]

Me again, sorry.
I have a table called ENEMY that holds... well enemies.
Every thing works as want so far apart from deleting from the table.

I have two enemies at the moment.
Number 1 is a snake.
Number 2 is a spider.

Then I have this to kill them off:

 ``` for en=1,#enemy do -- this line below stops working if box_hit(enemy[en].x,enemy[en].y) then if enemy[en].mode=="patrole" then plyr.hit_enemy = true plyr.struck_by_x=enemy[en].x end if enemy[en].mode=="dead" then plyr.hit_enemy = false end if enemy[en].mode=="pickup" then plyr.hit_enemy = false score+=enemy[en].score del(enemy,enemy[en]) end end end```

If I kill the spider first, it works.
If I kill the sname first it throws an error attempt to index field '?' a nil value.

I put it down to the DEL line at the end.
Does it look correct or is there more to deleting from a table than I know of?

Many thanks
Peej

P#96363 2021-08-22 22:13

[ :: Read More :: ]

Hello all...
Would someone be kind enough to point me in the direction of where I should be looking to solve my screen boundary problem.

I'm slowly working on a scrolling platform game and all's working quite well. I have bad guys that bounce about when they get hit. I wanted to have these bouncing guys hit and bounce back from the screen edge when they collide rather than the map edge. Much like having a wall all around the area you're currently looking at.

I may be over thinking it but... when the screen scrolls to the left, for example, is the left most edge of the screen still 0 or is there some sort of display edge I should be looking into??

Thanks in advance and I hope this makes sense.

Cheers.
Peej

P#96281 2021-08-20 21:59

[ :: Read More :: ]

Hello all...
I have a maths problem.

I have two points, t1 & t2 that I want to find the centre of.
t1 & t2 are two point on the x axis.
Another object's x approaches this middle point.
I have this so far:

if flr(self.x+3) == abs(self.t1-self.t2)/2+abs(self.t1)

t1 minus t2 divided by 2 giving half the distance between the two, added on to t1.

This works if t1 is smaller than t2.

But it doesn't work if t2 is smaller than t1, because the the 'middle point' is off to the right of t2!!

Can anyone suggest a better formula for getting the middle of two points regardless of which one is smaller?

I'm stumped.

Many thanks for your time and I hope this makes sense....

Peej

P#95890 2021-08-11 20:48

[ :: Read More :: ]

Hello all.
I'm doing alright at the moment with the new Pico-8 and I'm typing away happily.
One problem though.... I seem to be typing 'self' a LOT and using loads of valuable characters and/or tokens.

Is there a simple way to cut back on the number of times I have to use 'self'?

Its probably really complicated and I thought I was doing well...

Peej

P#95156 2021-07-21 21:42

[ :: Read More :: ]

Hello all, again.
I'm trying to get my head around tables.
I thought it would be a good idea to store a table of the possible modes and enemy can be in, chase, pause, detect etc.
So the enemy could only be in one mode at a time without all the if statements.

I tried this:

 ```function add_new_enemy(x,y,type) add(enemy,{ mode={}, add(mode,{1,2,3}), x=x, y=y.... etc.```

Adding a table called 'mode' with values 1,2,3 (All in the name of experimentation.)

Similar to the last problem I asked about, I'm trying to just print the first value of 'mode'.
In the _draw I have this:

 `print(enemy[1].mode[1])`

But that print NIL

What am I doing wrong? is my table all wrong are is my print statement wrong?

Many thanks
Peej

P#95007 2021-07-17 22:16

[ :: Read More :: ]

Embarrassing question but please be gentle. I'm very new to all this.
I have this code: (Lower down there). It's a bit mock up really for this question.

Lower down still in my code I'm working on a collision detection bit that needs, among other things, the value of x.
As you can see, it's all referencing 'self' and I have NO IDEA how to get the x value from this line:

spr(17,self.x,self.y,1,1,false)

Many thanks
Peej

 ```function add_new_enemy() add(enemy,{ x=80, y=96, w=8, h=8, dx=rnd(2)-1, dy=rnd(2)-1, life=20, draw=function(self) spr(17,self.x,self.y,1,1,false) end, update=function(self) self.x+=self.dx self.y+=self.dy self.life-=1 if self.life<0 then del(enemy,self) end end }) end```
P#94873 2021-07-15 00:15

[ :: Read More :: ]

Hello all.
I'm brand new to all things Pico 8, having dabbled with programming since the 80s.
I'm having LOTS of problems though.

I added particles to my platform player.
I saw a tutorial about adding objects and function within them, so I tried to change my particle system.
It broke. The error says: Unclosed { but I can't find where I've gone wrong.
I apologise if this isn't how to post code on this.
Can someone help out, please. (This is trimmed down in the hope I don't over stay my welcome!)

function _init()
....
particle={}
end

x=x,
y=y,
t=0,
die=die,
dx=dx,
dy=dy,
grav=grav,
grow=grow,
shrink=shrink,
r=r,
c=0,
c_table=c_table

``````    draw=function(self)
if self.r<=1 then
pset(self.x,self.y,self.c)
else
circfill(self.x,self.y,self.r,self.c)
end
end,

update=function(self)
self.x+=self.dx
self.y+=self.dy
if self.grav then self.dy+=.5 end
if self.grow then self.r+=.1 end
if self.shrink then self.r-=.2 end
self.t+=1

if self.t>self.die then del(particle,self) end

if self.t/self.die < 1/#self.c_table then
self.c=self.c_table[1]
elseif self.t/self.die < 2/#self.c_table then
self.c=self.c_table[2]
elseif self.t/self.die < 3/#self.c_table then
self.c=self.c_table[3]
else
self.c=self.c_table[4]
end
end
})
end

function dust()
end

function runs()