Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Mudkip In Disguise

Pages: [1]
1
This looks very interesting. I would like to see a bit of an in-depth explanation about how this works.

2
Thank you!

3
I am trying to make a game where the player walks through rooms.
I can't figure out how to prevent the player from walking through the walls.
Move with WASD
if the screen is black when ran, press WASD

***Here is the code***
Code: QB64: [Select]
  1. 'COLOR VARIBLES AND STUFF
  2. MAPX = 15
  3. MAPY = 15
  4. PC = 7
  5. SC = 8
  6. FC = 6
  7. CC = 4
  8. x = 3
  9. y = 3
  10.     'This makes the map
  11.     jail:
  12.     DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  13.     DATA 1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,2
  14.     DATA 1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1
  15.     DATA 1,0,0,0,1,0,0,0,1,1,1,1,1,0,1,1
  16.     DATA 1,3,0,3,1,3,3,3,1,0,0,0,0,0,0,1
  17.     DATA 1,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1
  18.     DATA 1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1
  19.     DATA 1,1,1,1,1,1,2,1,1,1,1,1,0,1,1,1
  20.     DATA 1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1
  21.     DATA 1,0,0,0,0,0,0,0,1,0,1,1,1,1,0,1
  22.     DATA 1,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1
  23.     DATA 1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1
  24.     DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
  25.     DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
  26.     DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
  27.     DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  28.  
  29.     'KEYPRESSES
  30.     PRINT MID$(PSCANY$, y - 1, y - 1)
  31.     K$ = LCASE$(INKEY$)
  32.     IF K$ = "w" THEN
  33.         y = y - 1: u = 1
  34.         IF a = y AND u = 1 AND num = 1 THEN
  35.             y = y + 1
  36.         END IF
  37.     END IF
  38.     IF K$ = "s" THEN
  39.         y = y + 1: d = 1
  40.         IF a = y AND d = 1 AND num = 1 THEN
  41.             y = y - 1
  42.             d = 0
  43.         END IF
  44.     END IF
  45.     IF K$ = "a" THEN x = x - 1: l = 1
  46.     IF K$ = "d" THEN x = x + 1: r = 1
  47.     IF K$ = "w" OR K$ = "s" OR K$ = "a" OR K$ = "d" THEN
  48.         'RENDER/UPDATE ROOM WHEN MOVEMENT IS DETECTED
  49.         PLAY "MB O1 GL64"
  50.         RESTORE jail:
  51.         DIM room(15, 15)
  52.         FOR a = 0 TO MAPX
  53.             FOR b = 0 TO MAPY
  54.                 READ room
  55.                 num = room
  56.                 IF num = 0 THEN
  57.                     LOCATE a + 1, b + 1
  58.                     COLOR CC, FC
  59.                     PRINT "_"
  60.  
  61.  
  62.                 END IF
  63.  
  64.                 IF num = 1 THEN
  65.                     LOCATE a + 1, b + 1
  66.                     COLOR PC, SC
  67.                     PRINT "°"
  68.                 END IF
  69.  
  70.                 IF num = 2 THEN
  71.                     LOCATE a + 1, b + 1
  72.                     COLOR 9, 12
  73.                     PRINT ""
  74.  
  75.  
  76.                 END IF
  77.                 IF num = 3 THEN
  78.                     LOCATE a + 1, b + 1
  79.                     COLOR 3, FC
  80.                     PRINT "Ñ"
  81.  
  82.  
  83.                 END IF
  84.                 u = 0
  85.  
  86.  
  87.                 LOCATE 20, 10
  88.             NEXT b
  89.  
  90.         NEXT a
  91.  
  92.         'DRAW PLAYER
  93.         LOCATE y, x
  94.         COLOR 14, 0
  95.         PRINT ""
  96.         _DISPLAY
  97.         CLS
  98.  
  99.  
  100.     END IF
  101.  

Pages: [1]