Page 2 of 3

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

Posted: Thu Aug 01, 2019 2:06 pm
by Einar Saukas
patters wrote: Wed Jul 31, 2019 11:04 pm
Einar Saukas wrote: Wed Jul 31, 2019 9:40 pmHowever, gameplay works much better if the gate becomes gradually narrower after each level, instead of reducing size only once at level 10. This change will also make this code a lot shorter.
I also spent some time coding that then I realised it results in quite significant red colour clash (more so than for the obstacles). Also I saw some collision detection issues relating to the grid alignment and only checking every 2 pixels of line progression, so this deterred me from implementing.
Both problems can be solved also replacing this:

Code: Select all

FOR x=5 TO 125
with this:

Code: Select all

FOR x=5 TO 124
Now you will only get a single pixel of color clash at the gate at most, for a brief moment. It's much less noticeable than the color clash you already have whenever the line passes close to a star. Since you cannot completely avoid color clash in this new version anyway, I don't think it's worth it to sacrifice gameplay just to avoid one more case of color clash.

I wrote "sacrifice gameplay" because I think the game looks much more exciting when the gate gets gradually narrower after each level. Instead of 9 levels with a large gate, followed by 11 levels with a small gate. However that's just my opinion. It's your game so it's your decision!

patters wrote: Wed Jul 31, 2019 11:04 pm This is a great improvement because it means the game no longer needs instructions. To cover the only remaining non-intuitive aspect, I had wondered about putting LEVEL x/20 at the top left, to make it clear that there is a goal, but in my opinion it spoils the clean presentation.
Again, it's non-intuitive because many players won't read the instructions, they will assume the game doesn't have an ending so they won't persevere to finish it.

If the gate gets narrower after each level, this will provide a clear goal for them, without the need for explanations.

patters wrote: Wed Jul 31, 2019 11:04 pm I didn't really like that the gate has to start a fair bit wider without resorting to some scaling, which would add characters.
It will make the game more accessible in the beginning, and more challenging in the end. I don't think that's a bad thing.

patters wrote: Wed Jul 31, 2019 11:04 pm Thanks for the awesome work on all the other enhancements.
You are welcome!

patters wrote: Wed Jul 31, 2019 11:04 pm I have been able to reinstate the satisfying pattering sound of the obstacle placement and the level-up plink sound, which I think are actually quite catchy elements of the game. The only thing I'm not entirely happy with now is the death sound. I need it to be long enough you can see how you died before the screen is redrawn (without relying on a PAUSE), and I want it to be an irritating sound to contrast the nicer sounds. However, a single tone doesn't seem enough...
I'm sure we can save a few more characters, so you can add a second BEEP. How much more space do you need?

To save a few more characters, replace this:

Code: Select all

READ p,e,l,d$: ... FOR n=0 TO 1: PLOT 249-n,63+l: DRAW 0,n-57-l: DRAW n+n-248,0: DRAW 0,163: DRAW 247,0: DRAW 0,-n-57-l: NEXT n: ... DATA 23620,21,1,"//"
with this:

Code: Select all

READ p,l,d$: ... FOR e=19 TO 20: PLOT 268-e,63+l: DRAW 0,e-76-l: DRAW e+e-286,0: DRAW 0,163: DRAW 247,0: DRAW 0,-e-38-l: NEXT e: ... DATA 23620,1,"//"

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

Posted: Thu Aug 01, 2019 3:50 pm
by Einar Saukas
Here's how to save another 12 characters. Replace this:

Code: Select all

READ p,l,d$: ... POKE p+73,65: ... PRINT ... AT 20,28+d;d$(d TO ): ... POKE p*POINT (x+x,y),35: ... POKE p,3+34*(l=e): DATA 23620,1,"//"
with this:

Code: Select all

LET l=1: ... POKE 23693,65: ... PRINT ... AT 20,28+d;"//"(d TO ): ... POKE 23620*POINT (x+x,y),35: ... POKE 23620,3+34*(l=e)

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

Posted: Thu Aug 01, 2019 4:35 pm
by patters
Wow, more great optimisations. I almost suspect you'll be able to halve the size of this listing if you keep looking. :lol:

Using another loop to define "e" like that at the beginning is ingenious. Also in retrospect I have no idea why I defined d$ instead of slicing the string directly.

I'll do some more experimenting with the gate. The other thing about the gradual progression design is that the game difficulty will decrease, and I currently consider it to be just right: clearly difficult, but tantalisingly possible. Still, it's nothing that can't be tuned...

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

Posted: Thu Aug 01, 2019 7:52 pm
by hikoki
Nice!!
It's fun when you bump into the gate :x I agree that would be fun to see it narrowing sooner in the game.
Suggestion: put a max number of keystrokes on every screen. I think it'd be fun to see this number decreasing.

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

Posted: Fri Aug 02, 2019 1:59 am
by patters
I think Einar's example use of the unmodified variable 'l' for the gate sizing results in a gate that starts too wide (making it too easy for too long) and ends with it too narrow for my liking. I prefer to use 'l/2' which starts the gate 4 pixels wider than before (36px compared to 32px). It shrinks by two pixels every second level, finishing at 16px for level 20 (the previous small size).

I've had to resort to:

Code: Select all

LET g=INT (l/2)
because otherwise 0.5 rounding up makes a mess of the DRAW operations. Is there a better way?
I can't stop play testing this - I did just complete it again, very satisfying :)

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

Posted: Fri Aug 02, 2019 2:54 pm
by Einar Saukas
Can you please post your new listing?

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

Posted: Fri Aug 02, 2019 9:06 pm
by patters
Sure:

Code: Select all

LET l=1:
FOR d=1 TO 3:
  POKE 23693,65:
  LET g=INT (l/2):
  BORDER 0:
  CLS :
  INK 2:
  FOR e=19 TO 20:
    PLOT 268-e,69+g:
    DRAW 0,e-82-g:
    DRAW e+e-286,0:
    DRAW 0,163:
    DRAW 247,0:
    DRAW 0,-e-44-g:
  NEXT e:
  PRINT INK 3;"LEVEL ";l;AT 20,28+d;"//"(d TO ):
  INK RND*4+3.5:
  FOR n=-e TO l*3:
    PRINT AT RND*17+2,RND*25+4;"*":
    BEEP .0001,60:
  NEXT n:
  INK 8:
  LET y=85:
  PLOT 8,y:
  FOR x=5 TO 124:
    LET k=4*(INKEY$<>"")-2:
    LET y=y+k:
    POKE 23620*POINT (x+x,y),35:
    DRAW 2,k:
  NEXT x:
  LET l=l+1:
  BEEP .01,20:
  BEEP .01,30:
  POKE 23620,3+34*(l=e):
  BEEP .2,-20:
NEXT d:
DIM a$(32):
INK 1+5*(l=e):
FOR n=0 TO 10:
  PRINT AT n,0; OVER 1;a$;AT e-n,0;a$:
NEXT n:
PRINT AT 10,n; INK 7;"GAME OVER" AND l<e;"WELL DONE" AND l=e
I was thinking about the BEEPs that I wanted for the death and game over sound. The ones in my original game were just way too many characters, and in retrospect they're far less important than the sounds I've already incorporated, so I'm not too focussed on their inclusion. I'm ready to release this version via my itch.io page unless Einar can find some new optimisations (I have no doubt that he will :-)).

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

Posted: Fri Aug 02, 2019 9:13 pm
by patters
hikoki wrote: Thu Aug 01, 2019 7:52 pm Nice!!
Thanks!
hikoki wrote: Thu Aug 01, 2019 7:52 pm Suggestion: put a max number of keystrokes on every screen. I think it'd be fun to see this number decreasing.
This small change would slow the line down, and I really like how fast this runs especially on real hardware. Also, one technique for getting through some tight spaces is to hammer the button repeatedly, so I'm not sure this would enhance the game.

What do people think of the difficulty? I have completed it a few times and certainly find it addictive, but I'm wary of setting the skill level too high due to my high number of hours play testing, a bit like how Rafaele Cecco admitted in an interview that difficulty of Cybernoid is way too high for similar reasons. The key to success in this game is to carefully watch the screen during the time the obstacles are deployed and pick your trajectory at that time, rather than winging it.

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

Posted: Fri Aug 02, 2019 10:18 pm
by Einar Saukas
To produce exactly the same gate, replace this:

Code: Select all

LET g=INT (l/2): FOR e=19 TO 20: PLOT 268-e,69+g: DRAW 0,e-82-g: DRAW e+e-286,0: DRAW 0,163: DRAW 247,0: DRAW 0,-e-44-g: NEXT e
with this:

Code: Select all

FOR e=19 TO 20: PLOT 268-e,68.9+l/2: DRAW 0,e-82-l/2: DRAW e+e-286,0: DRAW 0,163: DRAW 247,0: DRAW 0,-e-44-l/2: NEXT e
In your current version, the gate reduces 2 pixels every 2 levels. However it's a more "elegant" solution to reduce 1 pixel every level, as follows:

Code: Select all

FOR e=19 TO 20: PLOT 268-e,69+l/2: DRAW 0,e-82.1-l/2: DRAW e+e-286,0: DRAW 0,163: DRAW 247,0: DRAW 0,-e-44-l/2: NEXT e

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

Posted: Fri Aug 02, 2019 10:34 pm
by patters
Great, thanks Einar. I do prefer one pixel per level, and shorter too - who can argue with that. Thanks for all the help, it's been very educational.
I shall upload the finished game to https://patters.itch.io/line, and update all the screenshots, credits, etc.

I now nominate IvanBasic to make the next one liner :lol:

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

Posted: Fri Aug 02, 2019 10:35 pm
by Einar Saukas
Replace this:

Code: Select all

LET k=4*(INKEY$<>"")-2
with this:

Code: Select all

LET k=2-4*(INKEY$="")

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

Posted: Fri Aug 02, 2019 10:45 pm
by Einar Saukas
Replace this:

Code: Select all

FOR n=-e TO l*3: PRINT AT RND*17+2,RND*25+4;"*": BEEP .0001,60: NEXT n: INK 8: LET y=85: PLOT 8,y
with this:

Code: Select all

FOR y=84-l*3-e TO 84: PRINT AT RND*17+2,RND*25+4;"*": BEEP .0001,60: NEXT y: INK 8: PLOT 8,y

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

Posted: Fri Aug 02, 2019 10:55 pm
by Einar Saukas
patters wrote: Fri Aug 02, 2019 10:34 pm Great, thanks Einar. I do prefer one pixel per level, and shorter too - who can argue with that. Thanks for all the help, it's been very educational.
I shall upload the finished game to https://patters.itch.io/line, and update all the screenshots, credits, etc.
You are welcome!

Can we have your permission to this program to ZXDB and host the file at other free websites too?

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

Posted: Fri Aug 02, 2019 10:55 pm
by Einar Saukas
patters wrote: Fri Aug 02, 2019 10:34 pm Great, thanks Einar. I do prefer one pixel per level, and shorter too - who can argue with that. Thanks for all the help, it's been very educational.
I shall upload the finished game to https://patters.itch.io/line, and update all the screenshots, credits, etc.
You are welcome!

Can we have your permission to this program to ZXDB and host the file at other free websites too?

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

Posted: Fri Aug 02, 2019 11:08 pm
by Einar Saukas
Here's just one more idea.

Since you have plenty of free space now, why don't you could play a short BEEP sequence before the game starts?

If you add a FOR/NEXT with variable 'l', then you can remove LET l=1 from the beginning, and also replace LET l=l+1 with NEXT l.

I mean, replace this:

Code: Select all

1 LET l=1: ... NEXT x: LET l=l+1: ...
with this:

Code: Select all

1 FOR l=-9 TO 0: BEEP .01,l+9: BEEP .01, l: NEXT l: ... NEXT x: NEXT l: ...
Give it a try :)

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

Posted: Sat Aug 03, 2019 12:02 am
by patters
Einar Saukas wrote: Fri Aug 02, 2019 10:55 pm You are welcome!

Can we have your permission to this program to ZXDB and host the file at other free websites too?
I'd prefer to confine it to itch.io at first because it offers some useful analytics and logging, then we can add it to ZXDB after a few weeks, like I did with Artillery.

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

Posted: Sat Aug 03, 2019 12:05 am
by patters
Einar Saukas wrote: Fri Aug 02, 2019 11:08 pm

Code: Select all

1 LET l=1: ... NEXT x: LET l=l+1: ...
with this:

Code: Select all

1 FOR l=-9 TO 0: BEEP .01,l+9: BEEP .01, l: NEXT l: ... NEXT x: NEXT l: ...
Give it a try :)
Hmm. I just tried that, but it seems to increment the level counter by two on each level completion which is odd, given that I tested something similar in BASIC out of curiosity just before implementing. I did definitely remove the LET l=l+1
EDIT - nevermind - it was my POKE jumping to the wrong statement number and hitting the first NEXT l again.

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

Posted: Sat Aug 03, 2019 1:54 am
by Einar Saukas
patters wrote: Sat Aug 03, 2019 12:02 am
Einar Saukas wrote: Fri Aug 02, 2019 10:55 pm You are welcome!

Can we have your permission to this program to ZXDB and host the file at other free websites too?
I'd prefer to confine it to itch.io at first because it offers some useful analytics and logging, then we can add it to ZXDB after a few weeks, like I did with Artillery.
Sure, no problem!

Thanks for allowing me to participate here, it was really fun! :)

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

Posted: Mon Aug 05, 2019 12:18 am
by patters
Final listing below. Einar, before I update my itch.io page, is there a better way to write that BEEP in the second statement?

Code: Select all

1 FOR l=-6 TO 0:
BEEP .02,(l+6)*5-10:
NEXT l:
FOR d=1 TO 3:
POKE 23693,65:
BORDER 0:
CLS :
INK 2:
FOR e=19 TO 20:
PLOT 268-e,69+l/2:
DRAW 0,e-82.1-l/2:
DRAW e+e-286,0:
DRAW 0,163:
DRAW 247,0:
DRAW 0,-e-44-l/2:
NEXT e:
PRINT INK 3;"LEVEL ";l;AT 20,28+d;"//"(d TO ):
INK RND*4+3.5:
FOR y=84-l*3-e TO 84:
PRINT AT RND*17+2,RND*25+4;"*":
BEEP .0001,60:
NEXT y:
INK 8:
PLOT 8,y:
FOR x=5 TO 124:
LET k=2-4*(INKEY$=""):
LET y=y+k:
POKE 23620*POINT (x+x,y),35:
DRAW 2,k:
NEXT x:
NEXT l:
BEEP .01,20:
BEEP .01,30:
POKE 23620,5+32*(l=e):
BEEP .2,-20:
NEXT d:
DIM a$(32):
INK 1+5*(l=e):
FOR n=0 TO 10:
PRINT AT n,0; OVER 1;a$;AT e-n,0;a$:
NEXT n:
PRINT AT 10,n; INK 7;"GAME OVER" AND l<e;"WELL DONE" AND l=e

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

Posted: Mon Aug 05, 2019 12:24 am
by Einar Saukas

Code: Select all

BEEP .02,l*5+20

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

Posted: Mon Aug 05, 2019 12:30 am
by patters
Thanks. Sometimes I can't see the wood for the trees.
Einar Saukas wrote: Sat Aug 03, 2019 1:54 am Thanks for allowing me to participate here, it was really fun! :)
Likewise, it was a good experience and I've learned many new techniques. It's an interesting form the one liner - a bit like the programming equivalent of writing a haiku :)

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

Posted: Mon Aug 05, 2019 8:30 am
by patters
I have updated https://patters.itch.io/line with the latest version.

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

Posted: Sun Mar 01, 2020 2:31 pm
by Dr beep
Although much shorter(only 6 pages), this topic brought me back to the OTHELLO oneliner development on WoS.