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 / RiiDii's mostly useful functions (DBPro)

Author
Message
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 10th Jun 2005 15:15
Welcome to RiiDii's mostly usefull functions.

The purpose is to post some of the mostly useful functions I've written and have yet to write. I'm posting it here in the 20 Line Coding Challenge section because I will also be compiling each set of functions into neat little packages that will easily fit into less than 20 lines. I will also include demo code that will not be included in the 20 line count. I will also attempt to post extended versions of the code that are easier to rip appart.

Please feel free to use these snippets
Please feel free to post your own useful functions
Please feel free to post comments, suggestions, bugs, etc.

Enjoy!

Here is the first mostly useful function. It's a series of four functions that create a sprite based menu. It should work fine for either 2D or 3D programs. The actual functions and set-up only take 6 lines with some room left over for more commands on those 6 lines.

20 Line Code:


Extended code:


"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 10th Jun 2005 15:35
Cool ima check this out now and post in a little bit. Good idea btw

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 10th Jun 2005 16:00
Here's some mostly useful functions (for 3D) I use regularly simply because they make coding easier. The demo only demonstrates a few of the functions. Most useful is probably the Make_Bullet and Move_Bullet functions for some very basic bullet wrangling. Oh, and there are a few angle calcs in the demo that can be useful.

20 Line Code:


Extended Code:


"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: 10th Jun 2005 16:16
Here's a mostly useful 3-liner that converts mass amounts of text into Data statements. It can save a ton of typing, and opens the doorway to some other possibilities. Just run the code in the background, copy some lines of text, then paste into the IDE (or wherever). Copy the word "exit" to the clipboard to shut the program down.



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
dj blackdragon3710
19
Years of Service
User Offline
Joined: 5th Nov 2004
Location: In LaLa land
Posted: 11th Jun 2005 02:18
Yay!!! Go R2 .

<<<<<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: 11th Jun 2005 11:41 Edited at: 14th Jun 2005 16:19
Thanks!

Edited:
Here's Timer-Based-Movement, Gravity and Bounce Function. The functions completely handles the Gravity and Bounce for you. No need to establish variables for each object. Just call the Gravity function with the Object Number, Acceleration, and Friction, and it works. Call the Bounce Function with the Object Number to force the Object to "Bounce" in the opposite direction.

This new modified code is easier to understand and much less code (although still 3 lines due to a compiler bug).

The demo purposely changes the Sync Rate to demo the timer-based-movement. You might notice a very slight jump as that happens, but it is barely noticeable.

20 Line Code:


Extended Code:


"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 11th Jun 2005 16:55
wow u just have all sorts of functions

here are mine(not nearly as cool though)




and not neccessarily a function but could work as a game server login system with a tad bit of editing




anyway
hope i didnt post too much code

formerly shadows of emptiness
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 12th Jun 2005 03:44
Thanks Offset.
Here's a compressed and updated GetIP() Function.
20 Line Code:


"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: 12th Jun 2005 04:09
And here's the updated DisableX() function, which basically disable's the [X] (close window button) in the upper-right corner of a given window.



"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: 12th Jun 2005 06:31
Painting Objects.
Have you ever wanted to 'paint' an object in DBPro? Bullet holes? Footprints? Shadows? Too difficult? Here's what you've been looking for! Less than 3 Lines of code (and a demo)! Paint any object any time. Make a few easy mods to the function for different types of decals. And all using DBPro 5.8 commads.

20 line code


Extended Code:


"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Three Score
19
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 12th Jun 2005 15:57
thanks for turning my code into 20 line
and nice painting code

formerly shadows of emptiness
dj blackdragon3710
19
Years of Service
User Offline
Joined: 5th Nov 2004
Location: In LaLa land
Posted: 14th Jun 2005 09:18
Yay R2. You just keep pumping them out . Good job.

<<<<<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: 14th Jun 2005 14:50
Here's an asteroid/rock primitive function using the new vertexdata commands. No lie here - I ripped this almost directly from JessTicular's web site for user based help files. So here it is with a plug to go see JessTicular's website. I plan on doing more primitives.

http://jessticular.dbspot.com/?nav=dbhelp

20 Line Code:





Extended code:


"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: 16th Jun 2005 14:34
I'm sure there must be plenty of uses for this one. These functions create a tringle copy of a triangle on an object that is closest to a source object. One immediate use that comes to mind is estimating an angle of impact on irregular shaped object. The demo uses spheres, but it should work on any object (excluding limbs).

It is a WIP, and has some limitations, such as not working on rotated objects. Any comments, suggestions, or uses for these functions is more-than welcome.

20-Line Code:


Extended Code:


"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: 17th Jun 2005 05:53
RainMaker: These 6 lines of code create a series of images that can be used as a sprite overlay to simulate rain. Once the images are created, the code runs a demo. During the demo, press [S] to save the images to .bmp files (or change the format, but I would not recommend .jpg). Then just load the files and cycle them through on a sprite with an alpha map setting of about 65 to add rain to your game. During the demo, use the arrows keys to move the camera around.

20 Line Code:


Extended Code:


"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
dj blackdragon3710
19
Years of Service
User Offline
Joined: 5th Nov 2004
Location: In LaLa land
Posted: 18th Jun 2005 01:55
Nice .

<<<<<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: 12th Aug 2005 07:45 Edited at: 13th Aug 2005 06:34
Been out for a while - bit of coder's block (like writer's block I guess). But I'm back and seem to be in-the-mood again. So here's a pretty good start for the return:

Star Scope effect for FPS games, complete with scanlines and greenish tint to everything. Pretty fast on the FPS too; I get over 300. It's less than 3 lines total (although it's split up into 4 lines).

20 Line Version:


I won't be posting the extended version anymore since Ric has posted a 20-Line-deCoder.

Edit: Improved the scan lines a bit.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 12th Aug 2005 11:57
All I get is a black screen. Possibly because all of your prestatic work is being done with no sync, turning sync off, or using a different bitmap before getting the images?

xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 12th Aug 2005 14:57
Wow, some excellent code snippets there. I really like the rain one and the paint on objects one. Very good stuff.

RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 12th Aug 2005 21:14
@LiT: There is a black screen for about 30 seconds or so during start up while it creates the static (yep, without a sync). After that, you should see something. I didn't use another bitmap because there was no need (since I wasn't syncing). Your posted pc specs look like they should work just fine (nothing more complex than alpha-mapping sprites). Odd. Maybe give a moment or two more? Also, version is 5.8 (though I think it should work in 5.7).

Thanks for the feedback. I'll take a look at it again and see if maybe a variable needs to be initialized for stability or something like that.

@xtom: Thanks for the feedback

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Jess T
Retired Moderator
20
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 13th Aug 2005 05:09
RiiDii,
Just noticed that plug for dbHelp, thanks mate

But, all the Vertex examples came from IceNine, so props to him for the addition of those commands to the database

Good work on all this code, too, looks really nice!

Team EOD :: All-Round Nice Guy
Want Better dbHelp Files?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 13th Aug 2005 06:22
Thanks Jess for the update on the source of those commands. They've been a real help in a lot of work I've done as of late.

Since I didn't say it before: Thanks IceNine for the work on the help on the Vertex commands! Sorry this is late. I shoulda-woulda-coulda looked a little closer at Jess' site for the proper on-time plug!

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

Login to post a reply

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