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 / StarFighter

Author
Message
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 4th Jun 2005 11:36
You're in a pretty tough ship trying to fend off a ton of little drone fighters. Who will win? Probably not you! But take as many with you as you can! Who wants to live forever?

Fast paced: Use the mouse to pitch up/down and turn left/right. Left mouse click to fire. Up key moves you forward. Down key moves you back. The fewer drones left when your shields drop - the better you've done.

Advice from StarFighter Command: It is possible to dodge a drone's beam once in a great while, but it's nearly impossible. Still - since it's a matter of life and death, every little bit counts. Your ship moves forward a lot faster than it moves backwards. Flying backwards is a great strategy for shooting the little buggers, but they will catch you. You can shoot much further than the drones can, but they can be damn hard to target at greater distances.

Enjoy



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 4th Jun 2005 19:41
nice drones and likr the way they move, will be unpacking this toto make it easier read.

well had 30 of the little drones to go how'd I do?

I'm not getting you down am I, Ho Look! another fancy Door?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 5th Jun 2005 00:55 Edited at: 5th Jun 2005 01:07
Thanks.
30 to 20 is about what I regularly have left. Have to see what others get.

Edit: If you want to know the basics of the drone AI, check out the code snippets - a post called Lock On Function. That's where the idea evolved from.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 5th Jun 2005 07:46 Edited at: 5th Jun 2005 07:55
Okay - did a bit of work on this today. New features for v1.2: Stars: give a sense of movement. If, by chance, you do manage to defeat the hoard of drones - you move on to the next level, and have to fight more drones (your shields get refereshed as well).

Enjoy!


"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Jun 2005 18:08
RiiDii Very nice space movement makes it feel that you are out there.

Also if there room left how about they exploed and take a few friends with them


Also what this bit do in the code?
#Constant ObFunc
ObFunc :

I'm not getting you down am I, Ho Look! another fancy Door?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 5th Jun 2005 22:49
I've got about 22 commands left without rewritting the whole thing. I might give something like that a shot. I was also thinking they should die and take some shields if they hit you.

I'll post the answer later.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Jun 2005 03:51 Edited at: 6th Jun 2005 03:55
#Constant pretty much does a find/replace during compile. Everything after (on the same line) the "#Constant ObFunc :" replaces "ObFunc" anywhere in the code. I use it kind of like Function, but unlike Function - I don't need an EndFunction on the next line. I can also stick them at the end of any line that hasn't used it's full 25 commands - even inside a Function. So now, structure doesn't mean that much using #Constant - it's pretty easy to use all 25 commands for all 20 lines for a total of 500. Also, since it's reuseable, like functions, you can really add far more commands - with a little creative coding.

Specifically, the ObFunc is a series of common Position functions, like Object Position X or Limb Position Z. It checks for and pulls them all. Not very resource friendly, but very line conservitive. I also have 4 types of objects to check for: Object, Target, AI, and camera. Object is just any object, as is Target, but I wanted two calls with two return values so I could use them to compare (one at a time just didn't work so well). AI is a default Object that I usually set as Object #2. Using the default AI value allows me to save commands by not having to declare a line ObjectID=2. And Camera, though not used in this code, returns the camera's postion.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Jun 2005 05:04
Okay - here's some screen shots. First: Made it to Level 3. Level 3 is pretty darn tough.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II

Attachments

Login to view attachments
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Jun 2005 05:05
And here's one of getting caught in the crossfire.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 6th Jun 2005 06:30
Cheers RiiDii , unstand what its doing, but how your doing will take bit more studying.

I'm not getting you down am I, Ho Look! another fancy Door?
dj blackdragon3710
19
Years of Service
User Offline
Joined: 5th Nov 2004
Location: In LaLa land
Posted: 6th Jun 2005 07:23
Quote: " And here's one of getting caught in the crossfire."


Ltterally, made it to 4 .

<<<<<Used to be "djblackdragon" with being registered in January, 2003, no matter what it says on the left<<<<<
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Jun 2005 07:47
Quote: "Ltterally, made it to 4"

I wasn't sure it was possible. Congratulations!

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 6th Jun 2005 08:45
I can't actually get this to work, what version/ide are you using?

Once I was but the learner, now, I am the Master.
See my site for amazing games and demos!
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th Jun 2005 09:21
Version = DBPro 5.8

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 7th Jun 2005 04:15
Is anyone else having problems with this? Also, if you would be kind and post any comments or feedback - I'd really appreciate it. I'll try to fix any problems that I can.

@The Darthster; what error message is it giving you? Also, is it during the compile or the execution?

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Ian T
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Around
Posted: 8th Jun 2005 11:29
Hi RiiDii,

Great game

Could I have a contact email please ? You could send it to my email if you're concerned about privacy. Thanks!

Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Jun 2005 05:06
Well Done ^_^

Mr Anderson
20
Years of Service
User Offline
Joined: 14th Oct 2003
Location: NYC
Posted: 23rd Jun 2005 05:58 Edited at: 23rd Jun 2005 06:00
Everyone must have a really fast computer. I experience slowdown when ever they fire. I have an AMD 2400+ and a nvidia 5200 FX and 512 memory running XP pro.

I can complie it I have DBpro 5.8...

Am I the only one with this issue?

IDIC (Infinite Diversity Infinite Combinations)
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Jun 2005 06:26
Try this... it might be a little faster.



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 23rd Jun 2005 10:34
i wouldn't worry Mr Anderson it crawls on this system too.. when you fire it's alright; but when the ships are firing just crawls to a stand still.

might take a look over it later

Keemo1000
18
Years of Service
User Offline
Joined: 26th May 2005
Location: 28th Dimension
Posted: 23rd Jun 2005 13:27
Could not determine parameter type of 'Function AIShoot(ObjectID)' at line 5

pls reply---
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Jun 2005 17:27 Edited at: 23rd Jun 2005 17:29
Quote: "but when the ships are firing just crawls to a stand still."

It creates a triangle as a place-holder for the 'beam'. In the original posting, the default collision setting was used; spheres. In the adjusted one, I set collision to boxes.

Also, all the stars (not the skybox) had collision on, again - by default. I set collision off for all the stars in the update.

These two should increase the speed considerably. There are probably a few other tweeks that can be made if needed.

Quote: "Could not determine parameter type of 'Function AIShoot(ObjectID)' at line 5"

What version of DBPro? This was written in 5.8. You might have to spread the code out to get it to work.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 23rd Jun 2005 22:48
Well I was talking about the updated version speed.
it might be using the DB/P Collision, it is quite slow even with Boxes.

I mean you only want to use the active collision sparingly, have Static Collision for everything else. Also another good idea to use Octree Collision Trees; so that you can then Queue the objects that could potencially be targets.

mm0zct
20
Years of Service
User Offline
Joined: 18th Nov 2003
Location: scotland-uk
Posted: 24th Jun 2005 00:16 Edited at: 24th Jun 2005 00:43
it doesn't seem to matter how fast or where i am moving when they fire my health always seems to just keep falling quickly until they stop, is there a way to evade their fire?
also is the fire rate supposed to be like one shot every 5-10 seconds?

edit: playing the faster vesrion with the run and snipe tactic i got to level three then quit because friends were talking to me on msn.

tip to anyone else just trying it for the first tme: hold forwards facing away for quite a long time and turn round, if you can't see them then they are beyond the camera range, then just use backwards away from where they should appear and snipe them untill they get a bit bigger, then repaet.

http://www.larinar.tk
AMD athlon 64 3000+, 512mb ddr400, abit kv8, 160gb hdd, gigabit lan, ati radeon 9800se 128mb.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 24th Jun 2005 01:27
Quote: "my health always seems to just keep falling quickly until they stop"

Each shot from an enemy is 1 point. On level 1, there are 100 of them to start with. That means each round of enemy fire, the shields will take 100 points of damage. The more drones you shoot (and the sooner you shoot them), the less damage you will take.

Quote: "is there a way to evade their fire?"

It is possible, but it's more luck than anything else. I originally made the enemy shot instant, which meant no dodging it. Then I added a slight delay (about 50 miliseconds at 60 FPS). This allowed for dodging maybe 1 or 2 out of a hundred shots.

Quote: "is the fire rate supposed to be like one shot every 5-10 seconds?"

Yes. It's timed out to be difficult, but not impossible. Also, at that rate, the firing strategy changes. At first, you just take pot-shots into the crowd and hit whatever is in the way. Later on when they are thinned out, you actually have to aim.

Quote: "i got to level three"

Level 4 seems to be the best so far.


Quote: "it might be using the DB/P Collision, it is quite slow even with Boxes."


It is. And even though I am moving away from using the built-in collision system, it's still efficient on total number of commands - something important for the 20 Line Challenge (and I know there was room left over).

Quote: "Also another good idea to use Octree Collision Trees; so that you can then Queue the objects that could potencially be targets"


I've thought of (and coded) similar concepts, where collision boxes are turned on and off as needed. I'd like to hear more about Octree Collision Trees.

I'll probably take a look at the code and update it a lot - make a StarFighter II. I'll look at enhancing the graphics, adding explosions, and improving the speed. Might try timer-based movement as well, but that adds a whole lot of commands, complications, and more commands to fix those complications. The TBM isn't the problem in itself so much as the collision system if suddenly, let's say, there is drop in FPS and the drones or the player suddenly moves a greater distance to compensate for the drop.

@ Raven, your advice has been very valuable and appreciated. Any suggestions/advice you can offer would be a great help. Thanks.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 25th Jun 2005 19:23
RiiDii where you go for your AI stuff, been looking at many sites but its all ?? ?? to me.

I'm not getting you down am I, Ho Look! another fancy Door?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 26th Jun 2005 04:04 Edited at: 26th Jun 2005 04:12
Most of the actual AI is simply turning based on getting distances from the player to the AI and the AI limbs. It was developed over in the Code Snippets forum here…

http://forum.thegamecreators.com/?m=forum_view&t=53827&b=6

But I think you have the wrong idea about AI. It’s not something you can just sit down and read a book about (although there are many good books on the subject of AI). AI is simply about telling the computer how to do a lot of little things that make it appear intelligent. The basics of AI are as simple as coding anything else. You start with Input, Processing, and Output. For example:

If I see a hammer heading towards my hand, this is input (visual input in this case). The my brain heads over to the files under “H” for Hammer-Impacting-Hand. Once the file is found, my brain reads through the file and figures out ‘this is going to hurt!’ This is processing. My brain, not being very fond of pain, tells my hand to “move it or lose it!” and my hand complies – avoiding the incoming hammer. This is the output. Put them all together, and I appear fairly intelligent because I didn’t hit my hand with a hammer.

Coding AI isn’t much more than that… except…

You have to code the input yourself
You have to create the conditions (“the file”) for processing
You have to code the output actions

In coding, Input can be many things. Keyboard commands, distances, angles, mouse movement, joystick input, even video cameras are being used now for input. Processing is typically If/Then or Select/Case statements, but can also be straight formulas. Output, for gaming, is usually some sort of movement or action command, such as move forward, turn left, or fire weapon.

In the case of StarFighter, the main input was distance.

What is the distance from the AI to the player? What is the distance from each of the limbs to the player?
The main processing was comparing those distances to pre-programmed values (distances) that I selected and fine-tuned, or compared to the distance to the other limbs in the case of turning. And finally for output, it was pretty much basic turning. If the right limb was closest to the player, then turn to the right. If the left limb was closest to the player then turn to the left. If the AI is too close to the player, then reverse all turning commands. If the AI is far enough way from the player, set all the turning commands back to normal.

So here’s how to teach yourself how to code AI.

Start by writing on a piece of paper (that white floppy fiberous material sitting in your printer) what you want a particular AI to do. Then break that down into smaller manageable components. Continue until you are pretty sure can’t break it down any more. Example:

AI attacks player
*AI turns towards player if far enough away
*AI turns away from player if too close
*AI shoots when player is in it’s “sites”

Then figure out each part of each AI step; Input, Processing, and Output. Example:

*AI turns towards player if far enough away
>>Input
--Get distance from player to AI
--Get distance from player to each limb

>>Processing
--If distance from player to AI is greater than 50
--If limb 0 is the closest limb
--If limb 1 is the closest limb
--If limb 2 is the closest limb
--(and so on)…

>>Output
--Normalize turning (not reversed)
--Don’t turn
--Turn Right
--Turn Up
--(and so on)…

Once you have a good idea what all your inputs, processes, and outputs are, the next step is to start coding. Not the game code, but test codes. I suggest writing functions for test codes, but you can use subroutines as well. Example: write a function that returns the distance between 2 objects.


Then test your functions individually. Example:


Once you have all you functions working to your satisfaction, then it’s time to put them together in your game code. Use your new functions just like any other code commands or functions. In no time, you will have a library of functions you can use for many purposes, and writing games will be quicker because you won’t have to start from scratch.

It’s really that simple. You may struggle with code along the way, but breaking your project and AI down in this manner will help you identify any roadblocks, be able to communicate those barriers to the forum community clearly and concisely, you will get a quick and comprehensive response, and be back to coding in no time.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 27th Jun 2005 04:45
RiiDii thank very much for your reply, given me plenty to think about, the last bit on how to go about very usefull.

Hope I can work out how to do this to my 3d connect 5 game, works ok if there are two humans playing it, and even then, if there's winning line you miss a seeing it.

Read lots on making maps of winning code and blocks, but as you said above, may just need to work out something that I have made and I know what it is doing.

Cheers

I'm not getting you down am I, Ho Look! another fancy Door?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 27th Jun 2005 07:25
Quote: "RiiDii thank very much for your reply"

You are very welcome.

Quote: "Hope I can work out how to do this to my 3d connect 5 game"

You can, that I am sure of. If you will, that's up to you. It may take a little time, so your most important skills to develop might be patience and determination.

Quote: "Hope I can work out how to do this to my 3d connect 5 game"

Start with a 2D connect 4 game. Just get the computer to be able to play it's pieces legally. You will learn a lot just doing that alone. Then take what you learn and apply it to your 3D game.
Even switch projects from time-to-time, but don't give up.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
The Ringmaster
19
Years of Service
User Offline
Joined: 19th Mar 2005
Location: Cyberspace
Posted: 1st Sep 2005 10:43
Im waiting for DBpro, my trial has timed out and im using DBC, can you please compile this?

Mr Anderson
20
Years of Service
User Offline
Joined: 14th Oct 2003
Location: NYC
Posted: 4th Sep 2005 14:12
Could the slow down be a video card issue. It literally is not playable when the things start firing. Its like taking snap shots. I wonder how come other people initially could play it with no problem.

It would be interesting to figure out why. For those that it runs fine, could you post your sys specs

I have dual xeon and 2g ram, with geforce 6800 GT, so I know I should not be having any problems unless there is something specific to my hardware and general enough that others can have it to cause the haulting.

Cheers

IDIC (Infinite Diversity Infinite Combinations)
IBOL
Retired Moderator
19
Years of Service
User Offline
Joined: 30th Mar 2004
Location: @IBOL17
Posted: 11th Oct 2005 21:37
hey rii,
i run 5.2 because it's stable (might switch to 5.9 if it solves more
problems than it creates)
i can not get you code to run at all...and i tried some things...
too bad, it looks interesting and gives me ideas.

Question:
i don't know much about #constants, BUT,
are you saying you can use #constant as a function somehow?
it looks like your code does that, but i can't be sure.

thanks,
bob

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 16th Oct 2005 21:01 Edited at: 16th Oct 2005 21:02
Kind of. #Constant does a find/replace before final compile of the code. So somethng like this:

#Constant wk :Wait Key
Print "Hello world."
wk


wil basically compile like this:

Print "Hello world."
Wait Key


(If you run the debugger, you will see a few differences, but that's the basics.)

You can stack commands as well, which would act pretty much like a function:

#Constant pwk : Print "Hello World":Wait Key
pwk


Will work just fine.

Nice thing about using #Constant in a 20-liner is that it can be used almost anywhere (even within a function), as long as it's the last command in the line (because anything that follows is considered part of the constant). So, it's usefull to throw in a small set of commands that are used several times in the code to finish out a line of code.

Note about using in the 20-Liner: I considered #Constant and the constant declaration to be a single "command", but if I used ":" to seperate out commands within a constant, I considered those as "new" commands, even though techinically they are still part of the #Constant declaration; in order to keep with the spirit of the 20-liner rules.

Side note: I've been warned that I might find a problem with doing things this way, but so far, there have been only minor annoyances on a few commands that don't work well with this method. But otherwise - it seems to be cool.


Open MMORPG: It's your game!

Login to post a reply

Server time is: 2024-03-29 15:28:06
Your offset time is: 2024-03-29 15:28:06