Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

The 20 Line Challenge / Quake III Arena!

Author
Message
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 13th Oct 2002 01:08
Almost! But, in 20 lines, what can you do that ID haven't done a million times better? I'm trying my best not to include external media in my 20-liners for your copy 'n' paste pleasure. Anyway, it's a two player shoot-em-up, controls are wasd and ijkl with space and right-ctrl to fire. First to 10 points wins. Again this is for dbpro since there's a 501 character line in there which dbv1 doesn't like. Oh, and multiple camera commands. To make the 20 line limit I had to sacrifice some stuff, like hide mouse, textures and sync. I'm going on the principle that if..else..endif, for..next, repeat...until and do..loop are all one command each. Here's the code:



I really hope this works, I've put the code tags in and separated the operators with spaces.
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 13th Oct 2002 01:13
Aaaannd it didn't work . Here's the code in un-tagged form:

dim x#(2):dim z#(2):dim oldx#(2):dim oldy#(2):dim oldz#(2)
dim cy#(2):dim shot#(2):dim fragged#(2):dim score#(2):create bitmap 1,2,2
cls rgb(255,255,255):get image 1,0,0,1,1:set current bitmap 0:delete bitmap 1:for i=1 to 2
make object cylinder 100+i,50:scale object 100+i,100,300,100:x#(i)=(int(rnd(1))*1600)+100:z#(i)=(int(rnd(1))*1600)+100:make object sphere 102+i,10
position object 102+i,-1000,-1000,-1000:make camera i:next i:set camera view 1,0,0,640,240:set camera view 2,0,240,640,480:dim level(138)
data 2,2,4,2,7,2,8,2,2,3,4,3,5,3,4,4,7,4,9,4,2,5,4,5,6,5,7,5,9,5,1,6,2,6,4,7,5,7,7,7,8,7,2,8,3,8,8,8,6,9,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,3,4,6,8,8,3:for i=0 to 67:read level(i*2):read level((i*2)+1):if i < 65
make object box i+1,200,200,200:position object i+1,(level(i*2)*200)-100,100,(level((i*2)+1)*200)-100:make static collision box ((level(i*2)*200))-200,0,(level((i*2)+1)*200)-200,(level(i*2)*200),0,(level((i*2)+1)*200):else:make light i-64:set point light i-64,(level(i*2)*200)-100,50,(level((i*2)+1)*200)-100
color light i-64,rgb((i-64)*85,(3-(i-64))*85,0):endif:next i:make object box 100,2100,3000,2100:texture object 100,1:scale object 100,-100,-100,-100:position object 100,900,1400,900
hide light 0:set ambient light 10:make matrix 1,1800,1800,9,9:prepare matrix texture 1,1,1,1:do
for i=1 to 2:oldx#(i)=x#(i):oldz#(i)=z#(i):if keystate((i*6)+11)=1 and fragged#(i)=0:x#(i)=x#(i)+sin(cy#(i))*10
z#(i)=z#(i)+cos(cy#(i))*10:endif:if keystate((i*6)+25)=1 and fragged#(i)=0:x#(i)=x#(i)+sin(cy#(i)+180)*4:z#(i)=z#(i)+cos(cy#(i)+180)*4:endif:if keystate((i*6)+24)=1 and fragged#(i)=0
cy#(i)=wrapvalue(cy#(i)-4):endif:if keystate((i*6)+26)=1 and fragged#(i)=0:cy#(i)=wrapvalue(cy#(i)+4):endif:if spacekey()=1 and shot#(1)=0 and fragged#(1)=0:shot#(1)=1
position object 103,x#(1),100,z#(1):yrotate object 103,cy#(1):endif:if keystate(157)=1 and shot#(2)=0 and fragged#(2)=0:shot#(2)=1:position object 104,x#(2),100,z#(2)
yrotate object 104,cy#(2):endif:if shot#(i)=1:move object 102+i,30:endif:if get static collision hit(oldx#(i)-20,125-200,oldz#(i)-20,oldx#(i)+20,125+200,oldz#(i)+20,x#(i)-20,125-200,z#(i)-20,x#(i)+20,125+200,z#(i)+20)=1:x#(i)=x#(i)-get static collision x()
z#(i)=z#(i)-get static collision z():endif:if get static collision hit(object position x(102+i)-10,0,object position z(102+i)-10,object position x(102+i)+10,200,object position z(102+i)+10,object position x(102+i)-10,0,object position z(102+i)-10,object position x(102+i)+10,200,object position z(102+i)+10)=1:position object 102+i,-1000,-1000,-1000:shot#(i)=0:endif:if sqrt(((object position x(103)-object position x(102))^2)+((object position z(103)-object position z(102))^2)) < 30 and fragged#(2)=0
fragged#(2)=30:position object 103,-1000,-1000,-1000:shot#(1)=0:score#(1)=score#(1)+1:endif:if sqrt(((object position x(104)-object position x(101))^2)+((object position z(104)-object position z(101))^2)) < 30 and fragged#(1)=0
fragged#(1)=30:position object 104,-1000,-1000,-1000:shot#(2)=0:score#(2)=score#(2)+1:endif:if fragged#(i) > 0
fragged#(i)=fragged#(i)-1:ink rgb(fragged#(i)*8.5,0,0),0:text 320,(i*240)-120,"Fragged!!":if fragged#(i)=0:x#(i)=(int(rnd(1))*1600)+100
z#(i)=(int(rnd(1))*1600)+100:endif:endif:position camera i,x#(i),125,z#(i):rotate camera i,0,cy#(i),0:position object 100+i,x#(i),75,z#(i):ink rgb(255,255,255),0
text 20,(i*240)-220,"Frags:"+str$(score#(i)):if score#(i) >= 10:repeat:text 320,(i*240)-120,"Winner!":until escapekey()=1:end:endif:next i:loop
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 13th Oct 2002 01:42
Hmm... That un-tagged code works. It works best if you set it to fullscreen 640x480. By the way, creating your own levels is really easy, you can just replace the first 50 numbers in the data statement (up to ,0,0,) and the last 6 (after ,9,10,) with numbers of your own to make levels. Here are some examples (replace the whole data statement):

data 2,1,2,2,5,2,6,2,7,2,8,2,5,3,8,3,2,4,3,4,8,4,5,5,8,5,2,6,3,6,4,6,5,6,5,7,7,7,8,7,1,8,2,8,3,8,7,8,8,8,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,7,6,5,8,3,3

data 5,1,2,2,4,2,5,2,6,2,8,2,2,4,4,4,5,4,6,4,8,4,1,5,2,5,8,5,9,5,2,6,4,6,6,6,8,6,2,8,4,8,5,8,6,8,8,8,5,9,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,10,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,1,10,2,10,3,10,4,10,5,10,6,10,7,10,8,10,9,10,7,4,5,7,3,4

To create your own levels, use this simple method: draw a 9 by 9 grid, then label the sides 1 to 9 across and up. Fill in 25 squares, then type in the x and y coordinate of each one, for example 2,3. Keep the rest of the data statement the same except for the last 6 values, these are the position of the lights in your level, they are green, orange and red respectively. Add coordinates for these as you did the other blocks, and your level is ready! One thing - when you are fragged it will put you in one of the corners, it is essential to leave them empty when designing your level. I might write a tool to design levels if there is any demand.

Please tell me what you think!
Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 13th Oct 2002 02:11
Technically, you're only supposed to have 4 colons on one line. You could cut down a lot on those opening statements by making a multidimensional array eg "dim info#(2,9)...info#(a,b)" with a being the player number and b being the kind of info 1 for x, 2 for z, 3 for oldx, etc. This alone would turn 9 statements into 1, allowing you to come a lot closer to the letter of the rules. Regardless, no-one really pays all that much attention to the minor technicalities of the rules, since there's no end to the competition, and no prizes. Great job !

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
QuothTheRaven
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 13th Oct 2002 23:34
can you give this to us in compiled form for db users?
xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 14th Oct 2002 02:10
More than 1 camera my graphics card runs at a snails pace. Looks very good though.
Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 14th Oct 2002 12:08
Another suggestion: add a "randomize timer()" line in at the start, so the player really does turn up in a random position after each death.

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 14th Oct 2002 20:50
Here's the link for the compiled version:
http://www.mikeyben.org:5432/darkb/fpsin20lines.zip

Randomize timer() was one of the commands I took out so I could fit it into 20 lines. I might improve it with these suggestions, or I might make a proper fps.

I thought, since for...next if...else...endif etc are one command each, you can have lots of ghost commands (i.e. the end of loops) on one line. For example:



This should be within the rules even though it contains 104 colons on one line.
Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 16th Oct 2002 08:41
I think the way it works is you're only supposed to have 4 colons on one line, as opposed to limiting the number of commands, because you could say that x#(i)=(int(rnd(1))*1600)+100 is 3 commands, one assigning the array location a value, one INT, one RND. Using this sort of logic would outlaw most things that could be made, and put your program a lot further into illegal territory.

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
vivi
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 19th Dec 2002 16:37
The link doesn't work!!

WHY WAIT FOR GAMES.......MAKE THEM COME TO YOU
>>>>>>>>>>>www.shark-software.20m.com<<<<<<<<<<<
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Dec 2002 18:38
Cool game. I'm well impressed. Err... Can I nick it?
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 21st Dec 2002 22:30
That depends on what you want to nick... If you use even the tiniest bit of my code you must give me full credit!! Not really. You can use whatever you want, but if the code forms a significant portion of your game then I'd like some credit. Most of it is fairly standard stuff that I did off the top of my head in about an hour, standard mouselook and fps controls, a very basic level builder and some static object collision detection. It's nice for 20(!) lines.

The link works for me.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Dec 2002 13:41
That last bit was a joke, but when you break the program down into individual lines it certainly shows how to do the basics in an FPS. I find it amazing how much can actually be done in so few commands!
Rob K
Retired Moderator
21
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 22nd Dec 2002 22:02
@TheDarthster

Pretty good for a simple FPS demonstration

A personal fav. from the 20 line challenge so far.

NOBODY has a forum name as stupid as Darth Shader. I do.
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 23rd Dec 2002 00:58 Edited at: 27th Mar 2003 00:09
That's what's good about DB, the commands are powerful and flexible, and you don't need many of them to make something half-decent.

Darth Shader - I'm sure I could do much better with some media and no line limit, but for 20 lines it is fairly nice. Sometimes I amaze even myself :J.

See also - my first entry, Ripples 'n' Lights! Lots of broken code posts, only one actually works! The main aim was to show off my nice real-time water effects, but the lights are actually more noticeable and/or impressive.

Once I was but the learner,
now, I am the Master.
Skyone
21
Years of Service
User Offline
Joined: 30th Dec 2002
Location: United States
Posted: 30th Dec 2002 21:37
that's not that much lines, but who cares! if it works, good!

That's about right!
UberTuba
21
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Brittania
Posted: 19th Jan 2003 12:46
My problem was that it was too fast.

Life is a terminal disease.
You never survive it.
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 19th Jan 2003 13:28
Yeah, I left out sync because there was no room. For the same reason, I couldn't put any timer code in there to make it run slower. It was designed for my Athlon 2000+, if it's too fast you could try changing the movement step values.
Richard Davey
Retired Moderator
21
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 20th Jan 2003 16:46
Absolutely brilliant - this will be the 20-liner of the month in our upcoming DB newsletter (due out this week). The award was free membership to DBDN (if you are not already a member) so please email me your details and I'll create your account.

This will become a monthly thing btw - 20 liner winners. The winning code will appear in our newsletter and prizes given (they will vary from month to month)

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
DB Team / Atari ST / DarkForge / Retro Gaming
ShockFire
21
Years of Service
User Offline
Joined: 18th Jan 2003
Location: United Kingdom
Posted: 25th Jan 2003 21:59
Its more than brilliant, its a masterpiece!
I would of never of thought you could create something like that with so little code, you could of gave it to us compiled and asked us to guess how many lines of code it took lol

Login to post a reply

Server time is: 2024-03-29 00:08:20
Your offset time is: 2024-03-29 00:08:20