Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"5-line" engine
#24
(02-09-2024, 08:42 PM)bplus Wrote: I thought it was break even in byte counts between colon files and decolon files and unpacked MasterGy's nice little game made from Game Engine oh surprise! 400 bytes less with colons than without.

With more lines you have more CRLF's so for every colon you save CRLF's from line count
so you break even colon + Space = CRLF but with colons you have that much less lines.

So line counts 11+ versus 98 +  = 87 whoa! but I got 400 byte difference guess where all the extra bytes were?

Here is the breakdown for asci chars of significance:
I didn't know how to record it in text format (bas).

I played with the code a bit more.
-moving no wasd, moving ARROWS
-I replaced inkey with _keydown, so the movement of the puppet is smooth
-3 enemies with different identities. walks around the wall, moves horizontally/vertically, moves diagonally
(the structure of the 3 different moves compressed into 1 processing part)

the length of the code did not become longer, because there was something else I could take.
I kept to the original goal. If you want, you can put it all in 1 line, there is no IF.

Code: (Select All)
en = 6: gold = 12: c0 = 219: c1 = 46: c2 = 36: c3 = 35: c4 = 2: r(0) = 80: r(1) = 40 'en=enemies gold=golds 'c0,c1,c2,c3,c4 wall,street,gold,enemi,iam - ascii code of characters in order r(0)r(1)=map size

For t = 0 To 1: r(2 + t) = Int(r(t) / 2): p(t) = r(2 + t): d(t) = p(t): Next t

Randomize Timer: Screen _NewImage(r(0), r(1), 0): _FullScreen: _ControlChr Off

'make map
Color 6: _PrintString (1, 1), String$(r(0) * r(1), Chr$(c0))
For c = 1 To 4000: _PrintString (d(0), d(1)), Chr$(c1)
    t = Int(4 * Rnd)
    f = 0
    For a = 0 To 1
        b = a * 2
        l = t = b + 1
        d(a) = (t = b Or l) * (l * 2 + 1) + d(a)
        f = f Or d(a) = 1 Or d(a) = r(a) - 1
    Next a

    For t = 0 To 1
        d(t) = r(t + 2) * -f + d(t) * (-f Xor 1)
Next t, c

'make golds
Color 14
For c = 1 To gold
    Do
        For t = 0 To 1: g(t) = Int((r(t) - 10) * Rnd) + 5: Next t
    Loop While Screen(g(1), g(0), 0) <> c1 Or g(0) = r(2)
    _PrintString (g(0), g(1)), Chr$(c2)
Next c

'make enemies
For c = 0 To en - 1
    Do
        For t = 0 To 1
            en(c, t) = Int((r(t) - 10) * Rnd) + 5
        Next t
    Loop Until Screen(en(c, 1), en(c, 0), 0) = c1 And Screen(en(c, 1), en(c, 0) + 1, 0) = c0
Next c


'GAME cycle
Do
    Color 6: _PrintString (p(0), p(1)), Mid$(Chr$(c1), 1, c)
    m(0) = p(0): m(1) = p(1)

    'control me
    For t = 0 To 3
        e = ((t And 1) * 2 - 1) * _KeyDown(Val(Mid$("19712192002048018432", t * 5 + 1, 5)))
        q = Sgn(t And 2)
        m(q) = e + m(q)
        m = m Or e
    Next t
    c = Abs(m And Screen(m(1), m(0), 0) <> c0)

    For t = 0 To 1
        p(t) = m(t) * c + p(t) * (c Xor 1)
    Next t

    fg = -(Screen(p(1), p(0), 0) = c2)
    mygold = mygold + fg
    Sound 2000, .6 * fg

    Color 15: _PrintString (p(0), p(1)), Chr$(c4): m = 0

    'control enemies
    For c = 0 To en - 1

        die = die Or Screen(en(c, 1), en(c, 0), 0) = c4
        ti = c Mod 3 'which personality enemie
        t = en(c, 2) - (ti = 0) * 2
        Do
            t = t + (ti = 0)
            For w = 0 To 1
                b = (t + 16 + w) Mod 4
                d(w) = en(c, w) + (((b And 1) = 0) * ((b = 0) * 2 + 1)) * (ti <> 1) - (Sgn(t And (1 + w)) * 2 - 1) * (ti = 1)
            Next w
            u = Screen(d(1), d(0), 0)
            z = -(u = c0)
            t = (t - Int(4 * Rnd) * (z And (ti > 0))) Mod 4
        Loop While z

        Color 6
        _PrintString (en(c, 0), en(c, 1)), Mid$(Chr$(c1), 1, en(c, 3))
        en(c, 0) = d(0)
        en(c, 1) = d(1)
        en(c, 2) = t
        en(c, 3) = -(u = c1)
        Color 2: _PrintString (d(0), d(1)), Mid$(Chr$(c3), 1, en(c, 3))
        die = die Or (u = c4) Or (m(0) = en(c, 0) And m(1) = en(c, 1))
    Next c

    Do Until Len(InKey$) Or st
        _PrintString (1, 1), "Press a key to start"
    Loop: st = 1

    Color 6: _PrintString (1, 1), String$(50, Chr$(c0))

    _Limit 10

Loop Until _KeyDown(27) Or gold = mygold Or die
Color 15: Print Left$("you dead", -8 * die); Left$("congratulation!", -15 * (gold = mygold))
Reply


Messages In This Thread
"5-line" engine - by James D Jarvis - 02-06-2024, 02:13 PM
RE: "5-line" engine - by SMcNeill - 02-06-2024, 02:40 PM
RE: "5-line" engine - by James D Jarvis - 02-06-2024, 05:43 PM
RE: "5-line" engine - by bplus - 02-06-2024, 06:27 PM
RE: "5-line" engine - by GareBear - 02-06-2024, 10:42 PM
RE: "5-line" engine - by JRace - 02-07-2024, 01:30 AM
RE: "5-line" engine - by MasterGy - 02-07-2024, 02:31 PM
RE: "5-line" engine - by TerryRitchie - 02-07-2024, 02:46 PM
RE: "5-line" engine - by JRace - 02-07-2024, 05:25 PM
RE: "5-line" engine - by MasterGy - 02-07-2024, 08:27 PM
RE: "5-line" engine - by GareBear - 02-08-2024, 12:00 AM
RE: "5-line" engine - by SMcNeill - 02-08-2024, 12:15 AM
RE: "5-line" engine - by JRace - 02-08-2024, 03:43 AM
RE: "5-line" engine - by GareBear - 02-08-2024, 01:27 PM
RE: "5-line" engine - by SMcNeill - 02-08-2024, 05:13 PM
RE: "5-line" engine - by MasterGy - 02-08-2024, 05:22 PM
RE: "5-line" engine - by SMcNeill - 02-08-2024, 06:03 PM
RE: "5-line" engine - by SMcNeill - 02-08-2024, 07:12 PM
RE: "5-line" engine - by MasterGy - 02-08-2024, 11:01 PM
RE: "5-line" engine - by GareBear - 02-09-2024, 02:35 PM
RE: "5-line" engine - by SMcNeill - 02-09-2024, 03:23 PM
RE: "5-line" engine - by madscijr - 02-10-2024, 12:25 AM
RE: "5-line" engine - by GareBear - 02-09-2024, 05:48 PM
RE: "5-line" engine - by bplus - 02-09-2024, 08:42 PM
RE: "5-line" engine - by MasterGy - 02-09-2024, 09:24 PM
RE: "5-line" engine - by MasterGy - 02-09-2024, 09:51 PM
RE: "5-line" engine - by SMcNeill - 02-09-2024, 10:36 PM
RE: "5-line" engine - by MasterGy - 02-09-2024, 11:55 PM
RE: "5-line" engine - by bplus - 02-10-2024, 12:04 AM
RE: "5-line" engine - by MasterGy - 02-11-2024, 01:28 AM
RE: "5-line" engine - by SMcNeill - 02-11-2024, 01:35 AM
RE: "5-line" engine - by MasterGy - 02-11-2024, 04:22 PM
RE: "5-line" engine - by johannhowitzer - 02-12-2024, 02:41 AM
RE: "5-line" engine - by James D Jarvis - 02-15-2024, 06:59 PM
RE: "5-line" engine - by Pete - 02-16-2024, 10:05 AM
RE: "5-line" engine - by Jack - 02-16-2024, 11:06 AM



Users browsing this thread: 3 Guest(s)