I've made a one liner - called Line

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
Einar Saukas
Manic Miner
Posts: 949
Joined: Wed Nov 15, 2017 2:48 pm

Re: I've made a one liner - called Line

Post by Einar Saukas » Tue Jul 30, 2019 6:30 pm

You can remove this statement from the GAME OVER sequence:

Code: Select all

POKE q,1
At this point, you will already have INK 1 and PAPER 0. The only effect practical effect of this statement is to disable BRIGHT, but it's nearly impossible to distinguish brightness with these colors anyway.
0 x

User avatar
Einar Saukas
Manic Miner
Posts: 949
Joined: Wed Nov 15, 2017 2:48 pm

Re: I've made a one liner - called Line

Post by Einar Saukas » Tue Jul 30, 2019 7:17 pm

patters wrote:
Tue Jul 30, 2019 11:31 am
There is one slight edge case to my game. In order to keep the action reasonably fast I DRAW the line in increments of two pixels rather than PLOTing each point. Since the attributes are only checked every two pixels of line it's possible for the line to clip across the corner pixel of an obstacle and turn it blue without a collision. A necessary design compromise though...
To fix this bug, change the start position from (8,85) to (8,84).
0 x

User avatar
patters
Dizzy
Posts: 52
Joined: Thu Apr 11, 2019 12:06 am

Re: I've made a one liner - called Line

Post by patters » Tue Jul 30, 2019 8:04 pm

Great tips, from the master himself :)

I was just experimenting with the collision detection. The star character is quite small relative to the character block so I was wondering about whether to change it to use POINT rather than ATTR. Drawing each pixel on the line with PLOT is still considerably slower, but if I stick to DRAWing in increments of two I can validate the POINT status at both points for roughly the same overhead as one ATTR lookup. This would allow the line to really skim the obstacles and would make the game feel a lot more fair. Colour clash can be somewhat mitigated by making the entire playfield INK 1 and rendering the line with INK 8. This is less jarring than the line turning obstacles blue. I'll fold in your improvements and post a new version here to see whether people prefer it.
Last edited by patters on Tue Jul 30, 2019 8:06 pm, edited 1 time in total.
0 x
25 years in the making: Artillery projectile motion simulation
20 years in the making: Line a one line arcade game

User avatar
patters
Dizzy
Posts: 52
Joined: Thu Apr 11, 2019 12:06 am

Re: I've made a one liner - called Line

Post by patters » Tue Jul 30, 2019 8:05 pm

Einar Saukas wrote:
Tue Jul 30, 2019 7:17 pm
To fix this bug, change the start position from (8,85) to (8,84).
How did I not see that. :lol:
0 x
25 years in the making: Artillery projectile motion simulation
20 years in the making: Line a one line arcade game

User avatar
Einar Saukas
Manic Miner
Posts: 949
Joined: Wed Nov 15, 2017 2:48 pm

Re: I've made a one liner - called Line

Post by Einar Saukas » Tue Jul 30, 2019 9:04 pm

patters wrote:
Tue Jul 30, 2019 8:04 pm
Great tips, from the master himself :)
Thanks! :)

patters wrote:
Tue Jul 30, 2019 8:04 pm
I was just experimenting with the collision detection. The star character is quite small relative to the character block
I think it would look good to use the hash sign '#', but setting a different PAPER instead of INK.
0 x

User avatar
Einar Saukas
Manic Miner
Posts: 949
Joined: Wed Nov 15, 2017 2:48 pm

Re: I've made a one liner - called Line

Post by Einar Saukas » Tue Jul 30, 2019 9:17 pm

Einar Saukas wrote:
Tue Jul 30, 2019 9:04 pm
I think it would look good to use the hash sign '#', but setting a different PAPER instead of INK.
Another idea is to use either hash sign '#' or capital 'O', setting PAPER 1 and a different INK. It will give the impression there's a faint force field around each obstacle. This way, these obstacles won't look as blocky, but the collision will always seem correct.

Yet another option is using the copyright symbol that fills almost the entire character block, but I don't think it will look as good.
0 x

User avatar
patters
Dizzy
Posts: 52
Joined: Thu Apr 11, 2019 12:06 am

Re: I've made a one liner - called Line

Post by patters » Tue Jul 30, 2019 11:13 pm

Hmm. I've really convinced myself that ATTR collision detection is not a good fit here, so I've switched to POINT. The main issue is that as the later levels get congested with obstacles, the player needs to be able to cut a diagonal between closely packed obstacles. If you can't do this then it seems too unfair. This is a remake of a game I had played at school, and on that computer I'm pretty sure collisions were pixel accurate, so this feels more faithful.

Code: Select all

FOR l=1 TO 20:
POKE 23693,65:
BORDER 0:
CLS :
INK 2:
PLOT 2,170:
FOR n=0 TO 1:
DRAW 247,0:
DRAW 0,n+n-164:
DRAW n+n-248,0:
DRAW 0,163:
NEXT n:
PRINT INK 3;"LEVEL ";l:
FOR n=9+(l>9) TO 12-(l>9):
PRINT AT n,31; INK 1;" ":
NEXT n:
INK RND*4+3.5:
FOR n=0 TO l*3+20:
PRINT AT RND*18+1.5,RND*26+3.5;"*":
BEEP .0001,60:
NEXT n:
INK 8:
LET y=85:
PLOT 8,y:
FOR x=5 TO 125:
LET k=4*(INKEY$<>"")-2:
LET y=y+k: POKE 23620*POINT (2*x,y),34:
DRAW 2,k:
NEXT x:
BEEP .01,20:
BEEP .01,30:
NEXT l:
DIM a$(32):
BRIGHT 0:
INK 1+5*(l=21):
FOR n=0 TO 6:
BEEP .005,20-5*n:
NEXT n:
FOR n=0 TO 10:
PRINT AT n,0; OVER 1;a$;AT 21-n,0;a$:
NEXT n:
PRINT AT 10,n; INK 7;"GAME OVER" AND l<21;"WELL DONE" AND l=21
Download link

The game is a bit faster now which I think makes it more addictive, but it's a lot more achievable though still challenging. In fact I just completed it for the first time. I've improved the sound a bit, and added a completion screen. The collision detection is only checked every two pixels on the line, but I think with the current grid alignment it's working well. What do you think Einar?
0 x
25 years in the making: Artillery projectile motion simulation
20 years in the making: Line a one line arcade game

User avatar
patters
Dizzy
Posts: 52
Joined: Thu Apr 11, 2019 12:06 am

Re: I've made a one liner - called Line

Post by patters » Wed Jul 31, 2019 11:31 am

Here is a version which sacrifices the better sounds in order to offer the player three lives with a visual indicator in the bottom right of the screen. Given that the game runs faster, I think this is a good addition. In order to get it under the one screen limit I have had to re-use the 'e' variable a few times.

Code: Select all

READ p,q,e,l,d$:
FOR d=0 TO 2:
POKE q,65:
BORDER 0:
CLS :
INK 2:
PLOT 2,170:
FOR n=0 TO 1:
DRAW 247,0:
DRAW 0,n+n-164:
DRAW n+n-248,0:
DRAW 0,163:
NEXT n:
PRINT INK 3;"LEVEL ";l:
FOR n=9+(l>9) TO 12-(l>9):
PRINT AT n,31; INK 1;" ";AT 20,29+d;d$( TO 2-d):
NEXT n:
INK RND*4+3.5:
FOR n=0 TO l*3+e:
PRINT AT RND*18+1.5,RND*26+3.5;"*":
NEXT n:
INK 8:
LET y=85:
PLOT 8,y:
FOR x=5 TO 125:
LET k=4*(INKEY$<>"")-2:
LET y=y+k:
POKE p*POINT (2*x,y),34:
DRAW 2,k:
NEXT x:
LET l=l+1:
BEEP .02,30:
POKE p,3+33*(l=e):
BEEP .2,-e:
NEXT d:
DIM a$(32):
INK 1+5*(l=e):
FOR n=0 TO 10:
PRINT AT n,0; OVER 1;a$;AT 21-n,0;a$:
NEXT n:
PRINT AT 10,n; INK 7;"GAME OVER" AND l<e;"WELL DONE" AND l=e:
DATA 23620,p+73,21,1,"//"
Download link

Any further optimisations here that might allow the sounds as well, particularly the obstacle placement beep?
Last edited by patters on Wed Jul 31, 2019 1:03 pm, edited 4 times in total.
0 x
25 years in the making: Artillery projectile motion simulation
20 years in the making: Line a one line arcade game

Joefish
Manic Miner
Posts: 634
Joined: Tue Nov 14, 2017 10:26 am

Re: I've made a one liner - called Line

Post by Joefish » Wed Jul 31, 2019 12:30 pm

If it's only checking every 2 pixels, surely you need obstacles that have two-pixel thick lines so you don't skip straight through one?
0 x

User avatar
patters
Dizzy
Posts: 52
Joined: Thu Apr 11, 2019 12:06 am

Re: I've made a one liner - called Line

Post by patters » Wed Jul 31, 2019 12:34 pm

Joefish wrote:
Wed Jul 31, 2019 12:30 pm
If it's only checking every 2 pixels, surely you need obstacles that have two-pixel thick lines so you don't skip straight through one?
I have play tested it a lot and I think it's fine. The border lines are two pixels thick, and the stars don't really have corners to skip though if you're on a diagonal trajectory. Basically if you're going to clip the star at all you'll hit it with the subsequent pixel - mainly because of the current grid alignment (which can only change by 2 units at a time). Give it a try. I just updated the latest version btw. Had some issues with it which are now resolved, but it's been tricky to get it back under the one screen limit.
0 x
25 years in the making: Artillery projectile motion simulation
20 years in the making: Line a one line arcade game

Post Reply