0,ÿÿÿ™P$ÿÍuÿ¥D¦ö8ºe)6o;]ÉA¦ösï÷ÿ”°ÂVl†31<ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝýÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿÿÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÿÿÿÿÿÿÿÿßÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ3ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝBÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝDÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝîîÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝptÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÿÿÿÿÝÝÝÝßÝÝýÝÝÝÝßÿÿýÝÝÝÝßoöýÝÝÝÝßoöýÝÝÝÝßÿÿýÝÝÝÝßÝÝýÝÝÝÝÿÿÿÿÝÝÝÝ]UUUUUUUÕÝffffffffÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ]UUUUUUUÕÝffffffffÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ]UUUUUUUÕÝffffffffÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ]UUUUUUUÕÝffffffffÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝë-- title: Portal_shenanigans -- author: worst_game_dev -- desc: Basic portal test -- license: MIT License (change this to your license of choice) -- version: 0.1 -- script: lua --player variables local p={ sp=256,flip=0,x=24,y=88,xvel=0,max_x=8,xrun_vel=0,maxrun_x=1.2,yvel=0,max_y=8, w=3,h=6,xoff=2,yoff=2,acc=0.5,boost=3,vel=0,weight=1, running=false,falling=false,jumping=false,landed=false } --world variables local gravity=0.3 local friction=0.80 local mx,my,ml,mm,mr=mouse() local mouse_left_held=false local mouse_right_held=false local mouse_left_pressed=false local mouse_right_pressed=false local portal_goto_id=nil --portal variables local portals={ {active=false,x=nil,y=nil,rot=nil,c=5}, {active=false,x=nil,y=nil,rot=nil,c=6}, } local portals_on=false local in_portal=false local portal_orbs={} function TIC() --game world updates mx,my,ml,mm,mr=mouse() if ml and not mouse_left_held then mouse_left_pressed=true else mouse_left_pressed=false end if ml then mouse_left_held=true else mouse_left_held=false end if mr and not mouse_right_held then mouse_right_pressed=true else mouse_right_pressed=false end if mr then mouse_right_held=true else mouse_right_held=false end --portal updates update_portals() if portals[1].active and portals[2].active then portals_on=true else portals_on=false end for i=#portal_orbs,1,-1 do local orb=portal_orbs[i] --(rot)1=up,2=right,3=down,4=left if pix(orb.x+1,orb.y)==13 then portals[orb.id].x=orb.x portals[orb.id].y=orb.y portals[orb.id].rot=2 portals[orb.id].active=true table.remove(portal_orbs,i) elseif pix(orb.x-1,orb.y)==13 then portals[orb.id].x=orb.x portals[orb.id].y=orb.y portals[orb.id].rot=4 portals[orb.id].active=true table.remove(portal_orbs,i) elseif pix(orb.x,orb.y+1)==13 then portals[orb.id].x=orb.x portals[orb.id].y=orb.y portals[orb.id].rot=3 portals[orb.id].active=true table.remove(portal_orbs,i) elseif pix(orb.x,orb.y-1)==13 then portals[orb.id].x=orb.x portals[orb.id].y=orb.y portals[orb.id].rot=1 portals[orb.id].active=true table.remove(portal_orbs,i) elseif pix(orb.x+1,orb.y)==15 or pix(orb.x+1,orb.y)==5 or pix(orb.x+1,orb.y)==6 then table.remove(portal_orbs,i) elseif pix(orb.x-1,orb.y)==15 or pix(orb.x+1,orb.y)==5 or pix(orb.x+1,orb.y)==6 then table.remove(portal_orbs,i) elseif pix(orb.x,orb.y+1)==15 or pix(orb.x+1,orb.y)==5 or pix(orb.x+1,orb.y)==6 then table.remove(portal_orbs,i) elseif pix(orb.x,orb.y-1)==15 or pix(orb.x+1,orb.y)==5 or pix(orb.x+1,orb.y)==6 then table.remove(portal_orbs,i) end orb.x=orb.x+orb.dx orb.y=orb.y+orb.dy if orb.x<0 or orb.x>240 or orb.y<0 or orb.y>136 then table.remove(portal_orbs,i) end end if portal_goto_id~=nil and portals_on and not in_portal then local from=portal_goto_id local to=1 if from==1 then to=2 end local port=portals[to] local rot=portals[to].rot local xvel=p.xvel local yvel=p.yvel in_portal=true if rot==1 then p.x=port.x-4 p.y=port.y-4 p.yvel=math.abs(yvel) elseif rot==2 then p.x=port.x-4 p.y=port.y-4 p.xvel=-math.abs(yvel) p.yvel=xvel elseif rot==3 then p.x=port.x-4 p.y=port.y-4 p.yvel=-math.abs(yvel) elseif rot==4 then p.x=port.x-4 p.y=port.y-4 p.xvel=math.abs(yvel) p.yvel=xvel end portal_goto_id=nil end --player updates update_player() --draw cls() map() spr(p.sp,p.x,p.y,0,1,p.flip) for i=1,#portals do local port=portals[i] if port.active then local sprite=16 if port.c==6 then sprite=32 end if port.rot==1 then spr(sprite,port.x-8,port.y-8,0,1,0,2) spr(sprite,port.x,port.y-8,0,1,0,2) elseif port.rot==2 then spr(sprite,port.x+1,port.y-8,0,1,0,3) spr(sprite,port.x+1,port.y,0,1,0,3) elseif port.rot==3 then spr(sprite,port.x-8,port.y+1,0,1,0,0) spr(sprite,port.x,port.y+1,0,1,0,0) elseif port.rot==4 then spr(sprite,port.x-8,port.y-8,0,1,1,3) spr(sprite,port.x-8,port.y,0,1,1,3) end end end for i=1,#portal_orbs do local orb=portal_orbs[i] pix(orb.x,orb.y,portals[orb.id].c) end end --player specific code function update_player() --quick setup local acc=p.acc/p.weight local boost=p.boost/p.weight local max_x=p.max_x/p.weight local max_y=p.max_y*p.weight --apply world forces p.yvel=p.yvel+gravity if p.landed and not in_portal then p.xrun_vel=p.xrun_vel*friction p.xvel=p.xvel*friction else p.xrun_vel=p.xrun_vel*friction p.xvel=p.xvel*0.95 end if p.xvel<0.2 and p.xvel>-0.2 then p.xvel=0 end if p.xrun_vel<0.2 and p.xrun_vel>-0.2 then p.xrun_vel=0 end --movement if btn(2) then p.xrun_vel=p.xrun_vel-acc p.flip=1 elseif btn(3) then p.xrun_vel=p.xrun_vel+acc p.flip=0 end if btn(0) and p.landed then p.yvel=-boost p.jumping=true p.landed=false end --collision checks if p.xvel>max_x then p.xvel=max_x elseif p.xvel<-max_x then p.xvel=-max_x end if p.xrun_vel>p.maxrun_x then p.xrun_vel=p.maxrun_x elseif p.xrun_vel<-p.maxrun_x then p.xrun_vel=-p.maxrun_x end p.x=p.x+p.xvel p.x=p.x+p.xrun_vel local total_x=p.xvel+p.xrun_vel if total_x>0 then if collide_map(p,"R",1) and total_x>2 then mset(13,14,0) end local color=pix(p.x+p.xoff+p.w+p.xvel,p.y+p.yoff+math.floor(p.h/2)) if (color==5 or color==6) and portals_on then if color==5 then portal_goto_id=1 else portal_goto_id=2 end else in_portal=false if collide_map(p,"R",0) then p.x=p.x-p.xrun_vel p.x=p.x-p.xvel p.xrun_vel=0 p.xvel=0 end end elseif total_x<0 then if collide_map(p,"L",1) and total_x<-2 then mset(13,14,0) end local color=pix(p.x+p.xoff+p.xvel,p.y+p.yoff+math.floor(p.h/2)) if (color==5 or color==6) and portals_on then if color==5 then portal_goto_id=1 else portal_goto_id=2 end else in_portal=false if collide_map(p,"L",0) then p.x=p.x-p.xrun_vel p.x=p.x-p.xvel p.xrun_vel=0 p.xvel=0 end end end if p.yvel<-max_y then p.yvel=-max_y elseif p.yvel>max_y then p.yvel=max_y end if p.yvel>0 then p.falling=true p.landed=false end p.y=p.y+p.yvel if p.yvel>0 then local color=pix(p.x+p.xoff+math.floor(p.w/2),p.y+p.yoff+p.h) if (color==5 or color==6) and portals_on then if color==5 then portal_goto_id=1 else portal_goto_id=2 end else in_portal=false if collide_map(p,"D",0) then p.y=(math.floor((p.y+p.h+p.yoff)/8)*8)-p.h-p.yoff p.yvel=0 p.landed=true p.falling=false end end elseif p.yvel<0 then local color=pix(p.x+p.xoff+math.floor(p.w/2),p.y+p.yoff) if (color==5 or color==6) and portals_on then if color==5 then portal_goto_id=1 else portal_goto_id=2 end else in_portal=false if collide_map(p,"U",0) then p.y=p.y-p.yvel p.yvel=0 p.landed=false p.falling=true end end end end function animate_player() end --collisions function collide_map(obj,dir,flag) local x=obj.x local y=obj.y local w=obj.w local h=obj.h local xoff=obj.xoff local yoff=obj.yoff local x1=0 local y1=0 local x2=0 local y2=0 if dir=="L" then x1=x+xoff y1=y+yoff x2=x+xoff y2=y+yoff+h-1 elseif dir=="R" then x1=x+xoff+w y1=y+yoff x2=x+xoff+w y2=y+yoff+h-1 elseif dir=="U" then x1=x+xoff y1=y+yoff x2=x+xoff+w y2=y+yoff elseif dir=="D" then x1=x+xoff y1=y+yoff+h x2=x+xoff+w y2=y+yoff+h end x1=x1/8 y1=y1/8 x2=x2/8 y2=y2/8 if fget(mget(x1,y1),flag) or fget(mget(x1,y2),flag) or fget(mget(x2,y1),flag) or fget(mget(x2,y2),flag) then return true end return false end --portal specific code function update_portals() if mouse_left_pressed then fire_portal(1) end if mouse_right_pressed then fire_portal(2) end end function fire_portal(id) local mouse_x,mouse_y=mouse() local startx=p.x+p.xoff+p.w/2 local starty=p.y+p.yoff+p.h/2 local angle=math.atan2(mouse_y-starty,mouse_x-startx) local orb={ id=id, x=startx, y=starty, rot=0, angle=angle, dx=math.cos(angle), dy=math.sin(angle) } table.insert(portal_orbs,orb) end