Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 0 = AIR --
- -- 1 = WALLS --
- -- 2 = DOORS --
- -- 3 = SPRITE --
- x,y = term.getSize() -- Gets size of Current Computer Screen
- if x ~= 51 or y ~= 19 then
- error("SCREEN SIZE NOT AVALIBLE. 51 BY 19") -- Gives error if screen is bigger or smaller than 51 by 19 (colored or not).
- end
- function cls() shell.run("clear") end -- Short way of clearing the screen
- sx = 1
- repeat
- cls()
- term.setCursorPos(sx,1)
- print("Platformer Created by Just Does Games") -- splash screen. DO NOT REMOVE WITHOUT CONSENT FROM ME OR ELSE COPYRIGHT
- print("Version 1.0.0")
- sleep(.01) -- SAME FROM ABOVE APPLIES TO THIS LINE HERE TOO
- sx = sx + 1
- until sx == 15
- repeat
- cls()
- term.setCursorPos(sx,1)
- print("Platformer Created by Just Does Games") -- splash screen. DO NOT REMOVE WITHOUT CONSENT FROM ME OR ELSE COPYRIGHT
- print("Version 1.0.0")
- sleep(.01) -- SAME FROM ABOVE APPLIES TO THIS LINE HERE TOO
- sx = sx - 1
- until sx == 0
- sleep(.5)
- cls() -- Ignore
- write("Error Code: ") -- Ignore This 2
- room_1 = { -- EACH ROOM HAS ITS OWN STAGE CODE. IN THIS CASE, YOU START IN "room_1". IF YOU GO BEYOND THE SCREEN SIZE, IT CHANGES TO ROOMS 2-5.
- 1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, -- 1 = WALL 2 = DOOR.
- 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -- THE CODE ALLOWS THE COMPUTER TO PRINT THE MAP(S)
- 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, -- OF WHATEVER YOU WANT
- -- Player position. CHANGE IF YOU WANT THE PLAYER TO START IN ANOTHER POSITION
- load_room = room_1 -- THIS IS THE ROOM THAT LOADS FIRST. CHANGE THIS IF YOU WANT TO LOAD IN A DIFFERENT ROOM AT THE START OF THE GAME
- LR = true -- Ignore this
- running = true
- function load(table)
- if LR == true then -- This code prints the code on screen. WARNING: MAP DOES NOT UPDATE TO SAVE PROCESSING TIMES FOR PLAYER MOVEMENT
- load_room = table
- for i=1,#load_room do
- if load_room[i] == 0 then -- CHECKS TO SEE IF ITS 0. IF SO THEN
- write(" ") -- DISPLAY A BLANK SLOT
- elseif load_room[i] == 1 then -- CHECKS TO SEE IF ITS 1. IF SO THEN
- write("#") -- DISPLAY A WALL TILE
- elseif load_room[i] == 2 then -- CHECKS TO SEE IF ITS 2. IF SO THEN
- write(".") -- DISPLAY A DOOR TILE
- elseif load_room[i] == 3 then -- CHECKS TO SEE IF ITS 3. IF SO THEN
- write("*") -- DISPLAY SPRITE EXAMPLE
- end
- end
- end
- end
- while running do -- main player functions and map transactions
- term.setCursorPos(px,py) -- Ignore
- write(" ") -- Ignore
- term.setCursorPos(1,1) -- Ignore
- load(load_room) -- Ignore
- term.setCursorPos(px,py) -- Ignore
- write("@") -- Ignore
- a,i = os.pullEvent("key") -- Ignore
- if i == 17 or i == 200 then
- --if load_room[py * 51 - 51 + px] ~= 1 then
- py = py - 1 -- MOVES PLAYER UP /\
- --end
- if load_room[py * 51 - 51 + px] == 1 then -- CHECKS TO SEE IF CURRENTLY ON A 1 BLOCK BY USING THE AWSOME POINT TO ARRAY FORMULA I MADE! (playerx * screenx - screenx + playery)
- py = py + 1 -- MOVES THE PLAYER DOWN \/
- end
- elseif i == 31 or i == 208 then
- --if load_room[((py * 51 - 51)) + (px)] ~= 1 then
- py = py + 1
- --end
- if load_room[py * 51 - 51 + px] == 1 then -- CHECKS TO SEE IF CURRENTLY ON A 1 BLOCK BY USING THE AWSOME POINT TO ARRAY FORMULA I MADE! (playerx * screenx - screenx + playery)
- py = py - 1
- end
- elseif i == 30 or i == 203 then
- --if load_room[py * 51 - 51 + px] ~= 1 then
- px = px - 1
- --end
- if load_room[py * 51 - 51 + px] == 1 then -- CHECKS TO SEE IF CURRENTLY ON A 1 BLOCK BY USING THE AWSOME POINT TO ARRAY FORMULA I MADE! (playerx * screenx - screenx + playery)
- px = px + 1
- end
- elseif i == 32 or i == 205 then
- --if load_room[py * 51 - 51 + px] ~= 1 then
- px = px + 1
- --end
- if load_room[py * 51 - 51 + px] == 1 then -- CHECKS TO SEE IF CURRENTLY ON A 1 BLOCK BY USING THE AWSOME POINT TO ARRAY FORMULA I MADE! (playerx * screenx - screenx + playery)
- px = px - 1
- end
- elseif i == 28 or i == 32 or i == 57 or i == 205 or i == 18 then -- CHECKS TO SEE IF PLAYER HIT A SELECTION KEY. I HAVE THIS AS THE EXIT KEYS FOR NOW
- cls()
- running = false
- end
- if px > 50 or px < 2 then
- if px > 50 then
- if load_room == room_1 then
- load(room_3)
- else
- load(room_1)
- end
- else
- if load_room == room_1 then
- load(room_5)
- else
- load(room_1)
- end
- end
- if px > 50 then
- px = px - 49
- else
- px = px + 49
- end
- elseif py > 18 or py < 2 then
- if py > 18 then
- if load_room == room_1 then
- load(room_4)
- else
- load(room_1)
- end
- else
- if load_room == room_1 then
- load(room_2)
- else
- load(room_1)
- end
- end
- if py > 18 then
- py = py - 17
- else
- py = py + 17
- end
- end
- end
- print("Thanks for using 2d Engine!")
Advertisement
Add Comment
Please, Sign In to add comment