Hi,
Absolutely incredible cross-platform video game creation software!
As soon as I saw it for 1st time I purchased it.
Runs 100% perfectly on my "Manjaro Xfce 64Bit" Linux distro.
Started our 1st game project.
Need help with making source code smaller.
Please look at source code below and suggest changes.
Below source code does the following:
(1) Moves player's spaceship with [arrow] keys on keyboard.
(2) Fires player's laser beam with [z] key on keyboard.
Thank you in advance...
Jesse
www.FallenAngelSoftware.com
EDIT #1: HTML5 test version can be played below:
Click here to play!
-- "empire 2600 x2" -- "www.fallenangelsoftware.com" //---------------------------- function _init() plyrdir = 0 plyrx = 85 plyry = (64-4)+15 plyrspd = 0 bullavail = true bulldir = 0 bullx = -100 bully = -100 sky = {} for x = 1, 4 do sky[x] = { x = 0, y = 0 } end sky[1].x = 0 sky[1].y = 22 sky[2].x = (128/3) sky[2].y = 22 sky[3].x = ( (128/3)*2 ) sky[3].y = 22 sky[4].x = ( (128/3)*3 ) sky[4].y = 22 land = {} for x = 1, 4 do land[x] = { x = 0, y = 0 } end land[1].x = 0 land[1].y = 96 land[2].x = (128/3) land[2].y = 96 land[3].x = ( (128/3)*2 ) land[3].y = 96 land[4].x = ( (128/3)*3 ) land[4].y = 96 ship = {} for x = 1, 8 do ship[x] = {} for y = 1, 8 do ship[x][y] = 0 end end cls() spr(1, 1, 1, 1, 1, false, false) for x = 1, 8 do for y = 1, 8 do if ( pget(x, y) == 2 ) then ship[x][y] = 1 end end end end //----------------------------- function collisionland() for x = 1, 8 do for y = 1, 8 do if ( pget(((x-1)+plyrx), ((y-1)+plyry)) == 1 ) then if (plyrdir == 0) then if (ship[x][y] == 1) then return(true) end else if (ship[9-x][y] == 1) then return(true) end end end end end return(false) end //----------------------------- function _update() if ( btn(0) and (plyrx > 85-25) ) then plyrx-=1 plyrspd+=0.25 end if ( btn(1) and (plyrx < 85+25) ) then plyrx+=1 plyrspd-=0.25 end if (plyrx < 86) then plyrdir = 0 else plyrdir = 1 end if ( btn(2) and (plyry > -3) ) then plyry-=1 end if ( btn(3) and (plyry < 128-30) ) then plyry+=1 end if ( btn(4) and bullavail == true ) then bullavail = false bullx = plyrx bully = plyry bulldir = plyrdir end if (bullavail == false) then if (bulldir == 0) then if (bullx > -20) then bullx-=7 else bullx = -100 bullavail = true end else if (bullx < 128+20) then bullx+=7 else bullx = -100 bullavail = true end end end for x = 1, 4 do sky[x].x+=(plyrspd/2) if (sky[x].x < -30) sky[x].x = (128+30) if (sky[x].x > 128+30) sky[x].x = (-30) land[x].x+=plyrspd if (land[x].x < -30) land[x].x = (128+30) if (land[x].x > 128+30) land[x].x = (-30) end end //----------------------------- function _draw() cls() map(0, 0, 0, 0, 17, 17) for x = 1, 4 do sspr( (3%16)*8, (3\16)*8, 8, 8, sky[x].x, sky[x].y, 8*4, 8 ) sspr( (4%16)*8, (4\16)*8, 8, 8, land[x].x, land[x].y, 8*4, 8 ) end while ( collisionland() == true ) do plyry-=1; end spr(2, bullx, bully) playerflip = false if (plyrdir == 1) playerflip = true spr(1, plyrx, plyry, 1, 1, playerflip, false) print("[arrow] keys = move", 26, 1, 7) print("[z] key = fire", 26+10, 1+6, 7) end |
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/51095/3_AvatarRedCrown.png)
Hi,
This thread will not be updated anymore...
Please see new thread below:
https://www.lexaloffle.com/bbs/?tid=41411
Jesse
[Please log in to post a comment]