Games by younger me

Started by
14 comments, last by Josip Mati? 10 years, 9 months ago

Phew, weekend started, now I finally have time to be here a little XD

@Konrad Jablonski

Wow, game looks nice. As for the code... at least it's readable XD Now, if you would want to make one change, would you be able to do it without breaking whole thing? XXDD

@Arthur Souza

Thanks... I guess XD Wrote first thing which came to my mind, and LotR ended up being that...

@Orymus3

People learn whole life ^^ Luckily, I improved my code writing... curently I have about 30 classes of my own all communicating with other objects and/or inheriting other classes - something younger me wouldn't even think about doing.

What's even more embarrasing is that instead of using Rectangle to represent each board field and just use Rectangle.Contains(Point) method, I invented hot water. >.<

Advertisement

Phew, weekend started, now I finally have time to be here a little XD

@Konrad Jablonski

Wow, game looks nice. As for the code... at least it's readable XD Now, if you would want to make one change, would you be able to do it without breaking whole thing? XXDD

Well probably not, I haven't touched this code in over 3 years. Now I would use classes and functions for this like any normal person :)

When I started XNA, I used to load files whenever I needed them. I recently found my first pong game and I had Content.Load lines all over the place. The nice thing about XNA is that it still worked!! But with a bigger project you probably don't want Content.Load in the Update or Draw method -.-

If you see a post from me, you can safely assume its C# and XNA :)

I made multi threaded code without even knowing I was doing it before... that was many years ago.

That reminds me of how I still tend to avoid multithreading like the plague as if I had never used it... even after making a whole sound driver that has to cope with two completely different processors without any proper way to do handshake and the most atomic operation I can get is reading or writing a byte in RAM (I don't even get multibyte values!), which must be like the worst of the worst when it comes to multithreading =P

The only time I did it on PC (that didn't involve other library doing it for me - the one I mentioned before was not on PC) was recently in my game for the loading screen (otherwise the game can hang without pumping any events, which can make the OS think it got stuck and try to kill it). Given what I said above, I guess it shouldn't be surprising that it worked on the first try (even if it was quite simplistic).

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Goodie goodie, look what I found on my old PC from 1991 biggrin.png

Few years ago, I was bored on vacation and all other electronic devices were used by other family members, so I wrote this little gem in QBasic which needs serious refactoring:


CLS

DIM a, b, i, n, s AS INTEGER
DIM button AS STRING
DIM direction AS STRING
DIM x(100) AS INTEGER
DIM y(100) AS INTEGER

s = 0
n = 1
direction = ""
x(1) = 12 '25 max
y(1) = 40 '80 max
RANDOMIZE 1
a = INT(RND * 20) + 3
b = INT(RND * 77) + 2

COLOR 9
PRINT "Welcome to Aurioch's ASCII Snake"
COLOR 3
PRINT CHR$(201); STRING$(78, 205); CHR$(187)
FOR i = 1 TO 20
  PRINT CHR$(186); STRING$(78, " "); CHR$(186)
NEXT i
PRINT CHR$(200); STRING$(78, 205); CHR$(188)
LOCATE 1, 60
COLOR 12
PRINT "Score:"; S

DO
  FOR i = 1 TO n
    LOCATE x(i), y(i)
    COLOR 10
    IF i = 1 THEN
      PRINT CHR$(2)
    ELSE
      PRINT CHR$(254)
    END IF
  NEXT i

  LOCATE a, b
  COLOR 14
  PRINT CHR$(42)
  FOR i = 1 TO 5000 'delay
  NEXT i
  button = INKEY$
  FOR i = 1 TO n
    LOCATE x(i), y(i)
    PRINT " "
  NEXT i

  IF button = "w" THEN direction = "up"
  IF button = "s" THEN direction = "down"
  IF button = "a" THEN direction = "left"
  IF button = "d" THEN direction = "right"

  IF (direction = "up") AND (x(1) > 3) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    x(1) = x(1) - 1
  END IF

  IF (direction = "right") AND (y(1) < 79) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    y(1) = y(1) + 1
  END IF

  IF (direction = "down") AND (x(1) < 22) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    x(1) = x(1) + 1
  END IF

  IF (direction = "left") AND (y(1) > 2) THEN
    IF n > 1 THEN
      FOR i = n TO 2 STEP -1
        x(i) = x(i - 1)
        y(i) = y(i - 1)
      NEXT i
    END IF
    y(1) = y(1) + 1
  END IF

  IF (x(1) = a) AND (y(1) = b) THEN
    a = INT(RND * 20) + 3
    b = INT(RND * 77) + 2
    s = s + n
    n = n + 1
    IF direction = "up" THEN
      x(n) = x(1) + 1
      y(n) = y(1)
    END IF
    IF direction = "down" THEN
      x(n) = x(1) - 1
      y(n) = y(1)
    END IF
    IF direction = "left" THEN
      x(n) = x(1)
      y(n) = y(1) + 1
    END IF
    IF direction = "right" THEN
      x(n) = x(1)
      y(n) = y(1) - 1
    END IF
    LOCATE 1, 66
    PRINT s
  END IF

LOOP UNTIL button = CHR$(27)
COLOR 7
END

Yesterday, I was rewriting it on my laptop and noticed that I made game loop without knowing about it at all XD

This topic is closed to new replies.

Advertisement