### Author Topic: Light  (Read 11700 times)

0 Members and 1 Guest are viewing this topic.

#### Michael_Lee

• LV9 Veteran (Next: 1337)
• Posts: 1019
• Rating: +124/-9
##### Light
« on: October 17, 2010, 10:40:42 pm »
So I was thinking of making a new game, based around a single gameplay mechanic: light and shadows.
I was planning on making a rogue-like game (where you descend endlessly down a randomly generated dungeon, finding treasures, killing monsters, and avoiding traps and whatnot).
I decided that it would be cool to add light and shadow to the game, so that it's like you're in a DARK dungeon, emanating light (and it's scary - what could be lurking around the next corner?)

Sadly, it's extremely slow - this is an Axe assembly program going at full speed on an TI-84+SE, and moving the circle feels like pulling teeth.

(I'm using a variant of Bresenham's line algorithm, for those interested)

Also: how fast does pxl-Test work?  And the line( command?

Code: [Select]
.LIGHTFullDiagnosticOffFix 5Fix 9Fix 0ClrDrawClrDraw[radians][FFFFFFFFFFFFFFFF]->PIC1[3844828282443800]->PIC245->A->B0->Csub(MAP)Pt-On(A-3,B-3,PIC2)DispGraph::While 1If getKey(15)Goto ENDEndgetKey(1)-getKey(4)->EgetKey(3)-getKey(2)->DIf D or EClrDrawA+D->AB+E->Bsub(MAP)For(C,0,64)sub(LIN,A,B,96,C)sub(LIN,A,B,0,C)EndFor(C,1,95)sub(LIN,A,B,C,64)sub(LIN,A,B,C,0)EndPt-On(A-3,B-3,PIC2)0->CDispGraph:End::EndLabel MAPFor(F,0,7)For(G,0,1)Pt-On(G*16,F*8,PIC1)Pt-On(G*16+72,F*8,PIC1)EndPt-On(F*8+16,0,PIC1)Pt-On(F*8+16,56,PIC1)EndPt-Change(16,24,PIC1)Pt-Change(72,32,PIC1)For(F,0,1)For(G,0,1)Pt-On(F*24+32,G*24+16,PIC1EndEndReturnLabel LINIf abs(R4-R2)>abs(R3-R1)->Uexpr([degrees]R1,[degrees]R2,2)expr([degrees]R3,[degrees]R4,2)EndR1>R3->Kabs(R3-R1)->S/2->Vabs(R4-R2)->TR2<R4*2-1->WR2->YFor(Z,R1,abs(R3-R1)+R1)If K2*R1-Z->XElseZ->XEndgetKey(15)*9+W->WReturnIf getKey(15)If UIf pxl-Test(Y,X)Line(Y,X,R4,R3)ReturnEndElseIf pxl-Test(X,Y)Line(X,Y,R3,R4)ReturnEndEndV-T->VIf V>99Y+W->YV+S->VEndEndReturnLabel ENDFix 4
My website: Currently boring.

Projects:
Axe Interpreter
> Core: Done
> Memory: Need write code to add constants.
> Graphics: Rewritten.  Needs to integrate sprites with constants.
> IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
> Stomping bugs
> Internet version: On hold until I can make my website less boring/broken.

#### tloz128

• LV6 Super Member (Next: 500)
• Posts: 324
• Rating: +58/-6
• I feel asleep.
##### Re: Light
« Reply #1 on: October 17, 2010, 10:46:59 pm »
Woah! Pseudo 3d awesomeness!
Oh, and for optimizations, how about drawing the screen once every two runs through the loop instead of every time?
Naaa... Na Nah Na Nana Na Nah... Hey Jude!

#### meishe91

• Super Ninja
• LV11 Super Veteran (Next: 3000)
• Posts: 2946
• Rating: +115/-11
##### Re: Light
« Reply #2 on: October 17, 2010, 10:53:16 pm »
So is it kind of like a birds-eye-view 3D adventure type game? It looks cool, I hope you get the speed worked out
Spoiler For Spoiler:

For the 51st time, that is not my card! (Magic Joke)

#### SirCmpwn

• Guest
##### Re: Light
« Reply #3 on: October 17, 2010, 11:00:46 pm »
That is REALLY cool.  I do suggest making the shadows grayscale, however.

#### ztrumpet

• The Rarely Active One
• CoT Emeritus
• LV13 Extreme Addict (Next: 9001)
• Posts: 5712
• Rating: +364/-4
• If you see this, send me a PM. Just for fun.
##### Re: Light
« Reply #4 on: October 17, 2010, 11:03:29 pm »
That looks awesome!  By the way, if you think you can read the algorithms, there's this wonderful program: http://www.ticalc.org/archives/files/fileinfo/226/22637.html
I love that game on my 86.

Here's the source: http://www.ticalc.org/archives/files/fileinfo/226/22638.html
If I'm wrong, please correct me!
Unfinished Projects:
 Elmgon 14% Basic Movement Demo Homescreen Game Pack 80% Basic Latest Release Cube Droid Saves the Galaxy 65% Axe Demo Detonate 70% Axe
Completed Projects:
Exodus | Midnight |Drifter | Axe Snake | Jump! | Factory Theta | Spider | Plot Drop | Papi Jump | Numb3rs | Nibbler | Boost | Duel Tile Map Editor | Homescreen Map Editor | Key Group Check | Oasis

#### nemo

• LV9 Veteran (Next: 1337)
• Posts: 1203
• Rating: +95/-11
##### Re: Light
« Reply #5 on: October 17, 2010, 11:04:27 pm »
That is REALLY cool.  I do suggest making the shadows grayscale, however.

i second this. but instead of drawing lines to the backbuffer, draw the lines as you are now every other frame. that way you gain speed, and the shadows now appear gray.

#### meishe91

• Super Ninja
• LV11 Super Veteran (Next: 3000)
• Posts: 2946
• Rating: +115/-11
##### Re: Light
« Reply #6 on: October 17, 2010, 11:07:35 pm »
Oh, those are shadows! I totally thought those were like columns coming up at you That makes more sense now about the light thing. Ya, gray shadows would be cool
Spoiler For Spoiler:

For the 51st time, that is not my card! (Magic Joke)

#### AngelFish

• Is this my custom title?
• LV12 Extreme Poster (Next: 5000)
• Posts: 3242
• Rating: +270/-27
• I'm a Fishbot
##### Re: Light
« Reply #7 on: October 17, 2010, 11:21:53 pm »
(I'm using a variant of Bresenham's line algorithm, for those interested)

It looks awesome, but why are you using that algorithm? It could very well be faster to set the initial screen and adjust the start/end points of the Line( function (which already uses Bresenham's algorithm).
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

#### _player1537

• Guest
##### Re: Light
« Reply #8 on: October 17, 2010, 11:33:29 pm »
I think the algorithm is to allow a straight line to be drawn from the player to the next pillar (or from the pillar to the edge of the screen)  Qwerty is kinda right though, there is already a line routine written in ASM, if you can get the code for that routine and edit it apropriately, you can get the same routine but 9001% faster.  Quigibo released the source a long time ago, so you might want to look for it, if you (or anyone) can't find it, I'll edit my post.

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55876
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: Light
« Reply #9 on: October 17, 2010, 11:37:26 pm »
Wow that seems slow but looks AWESOME! It brought me back awesome memories from Blinded By The Dark! I hope you can make it faster.

#### Michael_Lee

• LV9 Veteran (Next: 1337)
• Posts: 1019
• Rating: +124/-9
##### Re: Light
« Reply #10 on: October 17, 2010, 11:38:10 pm »
(I'm using a variant of Bresenham's line algorithm, for those interested)

It looks awesome, but why are you using that algorithm? It could very well be faster to set the initial screen and adjust the start/end points of the Line( function (which already uses Bresenham's algorithm).

I'm using the algorithm to test when the shadows should start.  The algorithm tests all the points in the line, and when it encounters a black pixel, it switches over to the built in line( function to draw it.

--
Okay, grayscale it is!
--
Anybody know where I can find a TI-86 emulator?  I wanna try Blinded by the Dark.
« Last Edit: October 17, 2010, 11:39:58 pm by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
> Core: Done
> Memory: Need write code to add constants.
> Graphics: Rewritten.  Needs to integrate sprites with constants.
> IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
> Stomping bugs
> Internet version: On hold until I can make my website less boring/broken.

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55876
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: Light
« Reply #11 on: October 17, 2010, 11:43:31 pm »
There's VirtualTI on ticalc.org but you need a 86 ROM.

Btw what makes the grayscale faster than monochrome?

#### _player1537

• Guest
##### Re: Light
« Reply #12 on: October 17, 2010, 11:53:32 pm »
It makes it prettier

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55876
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: Light
« Reply #13 on: October 18, 2010, 12:22:53 am »
Ah ok.

#### _player1537

• Guest
##### Re: Light
« Reply #14 on: October 18, 2010, 12:26:18 am »
Actually, it just occured to me that it'd be *really* easy to add greyscale with the way greyscale is currently set up.  Store the layer you get from here, to the backbuffer, and copy-pasta the main image that you are doing collision tests with to the front buffer and blamo!  Greyscale shadows