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 / DBPro (media is 4Kb): 2D Vector-based Ocean Scene

Author
Message
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 12th Oct 2002 10:00
Woof. Finally got this done! Just a few minutes here and there when you're trying to get something done is tricky!

This one has 10 vectors moving across the screen to create an oceanscape scene with moving water, swimming fish, plants on the sea bed, and a sun (that sets and rises every other second, but that's beside the point ).

To improve load possibilities and increase the number of vectors I could put on screen, I did four major things:
1) switched from DATA statements to file-saved memblocks
1) added support for multiple vectors per file
2) stuffed the data into arrays
3) wrote a function to display any of the vectors in memory

You'll need to grab my media file...a whomping 3900 bytes! (can we say 4Kb competition here, gentlemen?) Here's the media:
Ocean Scene Data File

Here's the code to make it tick:
sync on: sync rate 40
open to read 1, "C:\Projects\james\20liner\ocean.dat":read long 1, filecount
for i = 1 to filecount:read long 1, filesize:make memblock i, filesize:read memblock 1, i:next i:close file 1
type point2d x as integer y as integer colournum as integer endtype:global dim colours(7,9) as dword:global dim points(7,200) as point2d:global dim pointnum(7) as integer
for j = 1 to filecount
mbposition = 0:pointnum(j) = memblock dword(j, mbposition):width = memblock dword(j, mbposition+4):height = memblock dword(j, mbposition+8):inc mbposition, 12
for i = 1 to 9:r = memblock dword(j, mbposition):g = memblock dword(j, mbposition+4):b = memblock dword(j, mbposition+8):inc mbposition, 12:colours(j,i) = rgb(r,g,b):next i
for i = 1 to pointnum(j):points(j,i).x = memblock dword(j, mbposition):points(j,i).y = memblock dword(j, mbposition+4):points(j,i).colournum = memblock dword(j, mbposition+8):inc mbposition, 12:next i
next j
wposx = -20:wposy = (screen height()/5)*2:curang=0:yfposx=-200:rfposx=screen width()+10:sunposx=-100
do:cls
curang = wrapvalue(curang + 3):sunposx = sunposx + 2: if sunposx > screen width() then sunposx=-100
yfposx = yfposx + 2: if yfposx > screen width() : yfposx = -100 : endif :rfposx = rfposx - 2: if rfposx
-= i only do what my rice krispies tell me to do =-
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 12th Oct 2002 10:03
hrm...not sure why those phantom code tags aren't working...let's try again...



oh, btw, please let me know if it works in your version of DBPro. I'm testing patch 2.2 (one of thost DBDN benefits) and didn't try a compile under the demo or the original release.

-= i only do what my rice krispies tell me to do =-
Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 12th Oct 2002 21:59
Keep in mind, the rules say max 5 commands on one line. That last one is just a tad too long. Not meaning to be picky, but it's best if you don't get into the habit of breaking the rules.

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 12th Oct 2002 22:13
hehehe: technically, I'm using function:endfunction and for:next in there and the only reason I have the command:
mycolour = points(VectorNumber,i).colournum
is because there is a bug with UDTs in DBPro.

it is only 18 lines long AND there are 6 lines with only 1 or 2 commands, so I'm hoping the forum will be forgiving with the *2* 6 command lines I have.

-= i only do what my rice krispies tell me to do =-
Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 13th Oct 2002 00:36
Ah, yes, I see the other one .

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 3rd Apr 2003 02:48
i'm bumping this one up...don't think anyone who's new has seen it and it is pretty cool ... for 2d.

-= i only do what my rice krispies tell me to do =-

Login to post a reply

Server time is: 2024-02-21 01:55:43
Your offset time is: 2024-02-21 01:55:43