Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Michael_Lee 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.
Any optimization suggestions, please?
(I'm using a variant of Bresenham's line algorithm, for those interested)
Also: how fast does pxl-Test work? And the line( command?
.LIGHT
Full
DiagnosticOff
Fix 5
Fix 9
Fix 0
ClrDraw
ClrDraw[radians]
[FFFFFFFFFFFFFFFF]->PIC1
[3844828282443800]->PIC2
45->A->B
0->C
sub(MAP)
Pt-On(A-3,B-3,PIC2)
DispGraph
::While 1
If getKey(15)
Goto END
End
getKey(1)-getKey(4)->E
getKey(3)-getKey(2)->D
If D or E
ClrDraw
A+D->A
B+E->B
sub(MAP)
For(C,0,64)
sub(LIN,A,B,96,C)
sub(LIN,A,B,0,C)
End
For(C,1,95)
sub(LIN,A,B,C,64)
sub(LIN,A,B,C,0)
End
Pt-On(A-3,B-3,PIC2)
0->C
DispGraph
:End
::End
Label MAP
For(F,0,7)
For(G,0,1)
Pt-On(G*16,F*8,PIC1)
Pt-On(G*16+72,F*8,PIC1)
End
Pt-On(F*8+16,0,PIC1)
Pt-On(F*8+16,56,PIC1)
End
Pt-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,PIC1
End
End
Return
Label LIN
If abs(R4-R2)>abs(R3-R1)->U
expr([degrees]R1,[degrees]R2,2)
expr([degrees]R3,[degrees]R4,2)
End
R1>R3->K
abs(R3-R1)->S/2->V
abs(R4-R2)->T
R2<R4*2-1->W
R2->Y
For(Z,R1,abs(R3-R1)+R1)
If K
2*R1-Z->X
Else
Z->X
End
getKey(15)*9+W->W
ReturnIf getKey(15)
If U
If pxl-Test(Y,X)
Line(Y,X,R4,R3)
Return
End
Else
If pxl-Test(X,Y)
Line(X,Y,R3,R4)
Return
End
End
V-T->V
If V>99
Y+W->Y
V+S->V
End
End
Return
Label END
Fix 4
-
Woah! Pseudo 3d awesomeness!
Oh, and for optimizations, how about drawing the screen once every two runs through the loop instead of every time?
-
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 :)
-
That is REALLY cool. I do suggest making the shadows grayscale, however.
-
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. ;D
Here's the source: http://www.ticalc.org/archives/files/fileinfo/226/22638.html
-
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.
-
Oh, those are shadows! I totally thought those were like columns coming up at you :P That makes more sense now about the light thing. Ya, gray shadows would be cool :)
-
Any optimization suggestions, please?
(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 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.
-
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. :)
-
Any optimization suggestions, please?
(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.
-
There's VirtualTI on ticalc.org but you need a 86 ROM.
Btw what makes the grayscale faster than monochrome? O.O
-
It makes it prettier :)
-
Ah ok.
-
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 :D
-
Yeah true, it's incredible how easy GS is to achieve in Axe compared to ASM and xLIB/DCS
-
This is looking awesome! Possibly to gain some speed, you could try 2x2 pixels instead of 1x1 and it would get 4 times faster maybe? You wouldn't be able to use the Axe line function but it sounds like you already have your own :D Me and Eeems were working on a similar game concept earlier but it didn't go anywhere. I looked into blinded by the dark code but i couldn't make any sense of it :( and they use some sort of tricky algorithm since it can have multiple light sources.
Overall i think this is looking awesome! :D
-
Builderboy, it could still go somewherw :p you and I just need to put our heads together more
-
/me wonders if that is related to their secret project or something :P
-
Its actually highly related ^-^
-
The problem with grayscale shadows is then you can see the whole map, regardless of where you are standing. Then the shadows become more of an effect that a gameplay mechanic.
(Is gameplay mechanic the right term here? I'm not really sure...)
I thought the entire idea of games like these is for you not to know what is around you without actually physically going there.
-
Yeah true, although maybe he plans to use the shadows to hide enemies and stuff, idk (Like Starcraft 2).
Btw nice to see you around again on the forums Michael :D
-
Looks great! Keep us posted!
-
The problem with grayscale shadows is then you can see the whole map, regardless of where you are standing. Then the shadows become more of an effect that a gameplay mechanic.
(Is gameplay mechanic the right term here? I'm not really sure...)
I thought the entire idea of games like these is for you not to know what is around you without actually physically going there.
Yeah true, although maybe he plans to use the shadows to hide enemies and stuff, idk (Like Starcraft 2).
Btw nice to see you around again on the forums Michael :D
Well, he could make it so anything in the shadows is grey, and the walls that you can see are black.
-
Any optimization suggestions, please?
(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.
Wabbit supports 86s, I think.
And btw, that looks awesome :D
EDIT: Yep, just tested. 86 works perfectly on Wabbit. Even 85s, even though they use the 86 skin.
-
I thought 86 support was limited and 85 absent?
-
Must have been a while ago. I kept bugging him about it until it worked ;D
-
After procrastinating for days (curse you, cuberunner!), I finally managed to implement a variant on Builderboy's suggestion and made the game check every two pixels for collisions.
Which means that now, instead of being excruciating, it's just a little slow! (Yay!)
Because I couldn't decide between black or grayscale shadows, I added both. You press alpha to alternate between the two. (I got a little lazy implementing it, so you have to come to a complete stop, press alpha really quickly if your emulator is fast, then start moving for it to switch).
Next: Collision detection. And plot. And more optimizing, if possible.
-
Looks good. Like I said earlier, if you're going to do greyscale shadows, I would make anything in shadows grey, otherwise there is no point.
-
Looks nice :D
-
Looks cool!
Random question, though: why did the screenie show "Asm " and not "Asm(" ???
-
Wow, how'd I miss this?
It looks great Michael! ;D
-
What MRide said about making sure shadowed objects are grey. Probably black is best (like Builderboy's Nightmare) , since it would add a *little* speed
After procrastinating for days (curse you, cuberunner!)
heh heh.... >:D
-
Well, coding is going along slowly, in fits and starts, but progress is being made.
I think I have a plot, and I want to run it through the forum to see what you guys think.
You control a villain (whose name, btw, is Harlequin) who lives in a lair in the depths of a maze. Because you are a villain (and a particularly nasty one, to boot), your maze is perpetually flooded with would-be heroes attempting to confront you. As a result, you're kept quite busy running about, resetting traps, killing tenacious heroes, etc.
One day, you were foiling heroes, as usual, when you accidentally triggered your own trap, which caused all of your equipment and stuff to scatter about, and more importantly, caused you to lose the all-important map of the maze, leaving you completely, totally, and utterly lost. Which sucks for you.
The purpose of the game is to go around collecting equipment from treasure chests, rearming (and avoiding) traps, killing heroes you encounter, recovering map pieces, solving puzzles by pressing buttons that open/shut pathways/doors, and attempting to convince henchmen that you are, in fact, Harlequin, and not some impostor.
-
Ooh nice, I like the idea, because it is not just the typical "A vilain with OVER 9000! magic powerz is threatening the kingdom and you must save the world" story style, which can be good, too, but different stuff is nice, sometimes. One thing I wonder, though: will there be NPCs and some form of shops or something to upgrade your equipment and to get clues?
Also I'll probably create a sub-forum for this later, unless Hot Dog beats me to it. :)
-
Ooh nice, I like the idea, because it is not just the typical "A vilain with OVER 9000! magic powerz is threatening the kingdom and you must save the world" story style, which can be good, too, but different stuff is nice, sometimes. One thing I wonder, though: will there be NPCs and some form of shops or something to upgrade your equipment and to get clues?
Also I'll probably create a sub-forum for this later, unless Hot Dog beats me to it. :)
Thanks!
I think I'll add interaction with various henchmen, as either sources of dialogue or to buy and sell stuff. (Pretty degrading stuff for a supervillain to stoop to,having to buy equipment from your own henchmen, lol)
-
Updates and screenshots will go in this thread.
November 2nd, 2010:
Real updates:
> Got shadows to respond faster
> Made character movement smoother
> Made the map scroll, not the character
Superficial updates:
> Switched to a new map
> Made tile engine slightly more extendable
> Made the viewing screen square, not rectangular. (Going to add stats and stuff to the right side)
Things I'm working on:
> Making a flexible tilemapper that can display more then walls
> Making the plot more detailed
Things I really need to start working on
> Adding interaction (traps, items, etc.)
> Adding menu systems
> Adding stats
Note:
I'm probably going to keep grayscale shadows the way it is now, so it functions as a way for me to easily see the layout of my maps and serve as a sort of lightbulb feature.
Another note:
Wheee!! This is fun, having a progress thread.
-
Awesome! Looks great!
-
There's a Full in there, I can tell. The screen messes up on the 84+.
EDIT: yes, when I put normal before every
DispGraph[sup]r[/sup]
and full after, it works
-
Worked fine on an emulated TI-84+. The source is included though, so you could always just fix it yourself :P
-
There's a Full in there, I can tell. The screen messes up on the 84+.
EDIT: yes, when I put normal before every
DispGraph[sup]r[/sup]
and full after, it works
Could you describe exactly how the screen messes up? If it's possible, could you also upload a screenshot?
-
It's kind of like this screenshot in Sprite Helpers (http://ourl.ca/4832/94303)
It's not your program, it's that grayscale messes up in Full mode.
(And in the link, look at the post just below the screenshots)
-
The delay is too slow for 15 MHz, so to use grayscale in 15 MHz you need to do:
Normal
DispGraphTheGame
Full
By the way that's awesome! I wonder if you should make the character move every 2 pixel or something so it is faster?
-
By the way that's awesome! I wonder if you should make the character move every 2 pixel or something so it is faster?
Well, that's actually what it's doing. Every time I move, the calculator starts crunching where to add the shadows two pixels later, but interrupts halfway through to display an intermediate circle position without rendering new shadows. Which is why the shadows are a little choppy but the circle isn't.
-
Oh ok, I meant the circle movement too
-
DispGraphTheGame
NNNNUUUUUUUUUU-
-
Lol. btw, Michael, I notice the room shows up for a little bit before the shadows appear. Maybe you could adjust the contrast so people can't tell?
-
There is another idea I had, but I think it might not look pretty all the time:
What about only updating certain portions of the screen in a frame, then another, then another? Would that help improving speed? Alternatively, you could update shadows less often, like the fog of War in Starcraft. In Starcraft, I think fog of war is updated at like 6 FPS max.
-
Update (mostly to prove that I'm not dead).
It's been proving nearly impossible to up the speed (and I don't really want to progress without increasing the speed of the shadows), but I've done some drastic optimizations to the shadow routine, so I think the problems in my tilemapping routine.
Also, I've been doing some planning, so I have the schematics of the first level done, I've planned out how health bars, items, and traps will go.
Right now I'm attempting to make a tilemap editor so I can actually try making a better tilemap.
After some tests:
Worst case scenario w/ simple map routine: 2.9 FPS
Normally: 2.8 FPS
x.x
-
It's been proving nearly impossible to up the speed (and I don't really want to progress without increasing the speed of the shadows), but I've done some drastic optimizations to the shadow routine, so I think the problems in my tilemapping routine.
Did you check out the smooth scrolling tilemapper thread? there were some insanely fast tilemappers in there.
-
I did. I'm working on deciphering Runer112's tilemap program, but I'm still not entirely sure how it works.
-
I think that's b/c it's crazy optimized. See if you can get the un-optimized version and compare the two.
-
I've been looking at the unoptimized one (the first one he released, I think?).
I looked at the uber-optimized one, and decided that that was an adventure for another day.
-
Oh. Yeah, I also have difficulty understanding someone else's code. I don't know what they were thinking when they wrote it. (Which is why commented code is much easier for me to understand)
Well, good luck! I hope you can make this faster. It's a really cool concept.
I have an idea for a different light-dark game, but that's on my "plan to plan to do list," so it will be awhile. :P
-
Well, crap. It's not my tilemap routine. *Sigh*
-
Actually, the speed looks better than before.
Have you considered not having the map scrolling every time you move?
-
Yeah it seems a bit faster. However, have you tried what I posted the other day (the post that contains a Youtube vid)? Would it help improving speed?
I'm glad this is still alive, though.
-
Hey, have you got any luck with this lately? I am wondering if you have considered toning down the complexity of the light engine by simply updating one row on the screen per frame or maybe even updating it only when reaching the middle of a tile?
This may not look as great, but maybe it would increase the speed?
I think the first method might not be feasible with Line, though. Maybe you would have to use a set of sprites with diagonal stuff drawn on them. Anyway here's what I mean:
-
I'm actually taking a small break on my project.
In my attempts to optimize, I entangled and combined many part of my program together in a manner that makes it tedious to pry apart/rewrite.
I'm still working on other parts, such as a tilemapper and the beginnings of the menu, but in order to allow me to get a fresh perspective on the problem, I'm currently working on another shorter project (with a demo which I can probably release either today or tomorrow, or at the latest, Saturday).
Unless I can get the shadow algorithm to run respectably fast, this project will probably have to be shelved indefinitely.
-
Ah ok I see, I'm glad you're still working on stuff. I hope this project doesn't die, though. Have you thought about posting your source so someone can figure out if he can help optimizing? Someone could maybe write an algorithm in ASM to do the lights part of your game.
-
Well, the most recent workable sources are all available on this thread. When programming on the highly volatile platform combined with the highly dangerous language that is Axe on z80 calculators, I generally think it's a good idea to disseminate sources as much as possible to guard against RAM crashes.
I think getting somebody to rewrite the portion in assembly might be a last-resort kind of idea, but I'll definitely keep it in mind.
[RANDOM THOUGHT]You should add the quote "I hope your project doesn't die" to your signature![/RANDOM THOUGHT]
-
Ah ok I forgot to check ;D
Hopefully a solution can be found. :)
At the very worst case you could always do it the Joltima way but have corners using triangle tiles instead of squares, or something like that.
EDIT: About signature edit... I had another idea recently, but I forgot. X.x
-
At the very worst case you could always do it the Joltima way but have corners using triangle tiles instead of squares, or something like that.
Wait, what?
*Music scratches to a halt
What would that do?
-
See first screenshot (animated):
http://www.ticalc.org/archives/files/fileinfo/76/7671.html
As for triangles I mean like this:
-
I did. I'm working on deciphering Runer112's tilemap program, but I'm still not entirely sure how it works.
I think that's b/c it's crazy optimized.
Correct! I often struggle to decipher my optimized code, which is why I usually try to force myself to add more comments than I think I need so I can understand it at a later time. However, it looks like I didn't comment my tilemapper much. Want me to go back and comment it?
-
Just try to make sure there aren't way too many either so it still fits in his RAM ;D (he could use it as external sub-routine I guess, though)
-
I did. I'm working on deciphering Runer112's tilemap program, but I'm still not entirely sure how it works.
I think that's b/c it's crazy optimized.
Correct! I often struggle to decipher my optimized code, which is why I usually try to force myself to add more comments than I think I need so I can understand it at a later time. However, it looks like I didn't comment my tilemapper much. Want me to go back and comment it?
I appreciate the offer, but I think I've managed to understand the tilemap moving part well enough that comments really aren't necessary. (The tilemap creation part, however, is... difficult to follow, but strictly speaking, I don't need it for my project). If you have time though, making the guide to Axe optimization that you mentioned on the tilemap thread would be pretty cool, though (poke, poke).
-
I did. I'm working on deciphering Runer112's tilemap program, but I'm still not entirely sure how it works.
I think that's b/c it's crazy optimized.
Correct! I often struggle to decipher my optimized code, which is why I usually try to force myself to add more comments than I think I need so I can understand it at a later time. However, it looks like I didn't comment my tilemapper much. Want me to go back and comment it?
Wait...you optimize your code so much you can't understand it? :o
EDIT: I have now passed the divide...
-
Another trick can also be to split your game source in sub-routines. That can help making the code easier to read.
-
True. I kind of wish that TI BASIC allowed things like C++, where the subroutines/procedures are all in one file. Like Axe.
-
Well, there's BasicBuilder, but it's not very reliable. Programs run slower, lots of pic stuff need to be renamed, xLIB/DCS sprite/map/pic commands won't work with internal BB pics, there are no archived program support and it's limited to 1 page apps. Hence why none of my old games use it.
-
Well, holy crap.
I wanted to see how fast Axe 0.4.7's new line commands were, so I compiled a version I had on the computer using both Axe 0.4.6 and 0.4.7 (see screenshots below)
If this is how the speed is like even without me fully using the new commands of 0.4.7...
My motivation just went up by over nine thousand. :hyper: :w00t: :hyper:
-
That is a nice increase. Very cool! =)
-
wow! that's a huge increase!
-
Woah that's a huge increase indeed! Does this means the project might be revived soon? :D
-
I second DJ's question. I hope you take this up again! :D
-
I second DJ's question. I hope you take this up again! :D
++
-
Is there a sample version that we can test with it? I wonder if you can increase the speed more.
-
Before today, I wasn't too sure if I would continue this project because I couldn't get the shadow effect to run at a fast enough speed to merit making any kind of game based on the effect.
However, with the faster line commands plus drawing lines to backbuffer, I could actually increase the speed even more (I hope)
Using the shadow effect is definitely feasible now, so I'll be resuming this project.
-
Yay! Good luck and best of wishes to you, sir! :D
-
Have you found even more speed optimizations right now?
-
Ah, well, not yet. After Christmas is always a bit busy (running around, cleaning, using up gift cards, etc), so I'll probably resume coding this evening.
-
Ah ok, good luck with all the stuff :D
-
Wow thats an awesome increase in speed! Is it running in 6Mgz or 15Mgz now?
-
MHz* :P
-
Still 15 MHz (sadly).
-
I think it's still good, though. I am really curious how the speed will increase when you change the things you planned to change, though.
-
Wow! This is a great increase. Excellent! ;D
-
Its an awesome increase :D I also had an idea. Might it be possible to have a beam of light (possibly 90 degrees) instead of a full circle? This would drastically reduce the amount of raycasting needed, and also might be used as a further game element.
-
You mean like in Nightmare? That might actually be more realistic, actually, since normally you can't even see behind you.
-
Out of curiosity, how are you casting your rays? Are you using a trig-based method, or the bresenham algorithm you posted in the routines thread a while back?
-
Its an awesome increase :D I also had an idea. Might it be possible to have a beam of light (possibly 90 degrees) instead of a full circle? This would drastically reduce the amount of raycasting needed, and also might be used as a further game element.
Yah, I guess I could do this, but I'm slightly worried about the possibility that the player might then just be lost because they lack enough info to know where they're going and they'll end up just stumbling around in the dark... (which is actually more realistic then I have now, but not as fun :P)
Out of curiosity, how are you casting your rays? Are you using a trig-based method, or the bresenham algorithm you posted in the routines thread a while back?
I'm using the bresenham algorithm, except much more optimized. I'll actually post what I have in a minute (although there aren't many improvements yet), as soon as I back up my calc...
-
Maybe what you could do is have a beam of light, but also have a circle of light around the player no matter what. (Basically the shadow beams always start out a certain distance from the player before they can start casting shadows). That way it still has a beam but you can still see whats really close to you.
You should check out this game http://www.kongregate.com/games/Jiggmin/neverending-light it has a shadow effect and is one of my most inspirational and favorite flash game :)
-
AWESOME
-
Steelm, I've noticed you seem to be spamming the forum with random single word comments. Please refrain from posting spam if you don't have anything constructive to say, as well as try to look at the post date to make sure you are not posting on threads that have died out a while ago. This is a warning, any more spam and you will be banned.
-
On a side note did he get any PM warning? I generally warn via PM but sometimes people won't notice (not that it matters, though. If I ever ban someone I put in the ban message that the person was warned already)
-
nice program
-
I wonder if this engine could be used for a pseudo-3D game... When I look at the screenshots I think GTA.
-
Hmm that might be a bit too much for Axe, but I guess it wouldn't hurt to try. I hope Michael works again on this eventually by the way.
-
Just realized it's a lot like this game: http://www.addictinggames.com/arcade-games/find-exit-game.jsp
Maybe try porting it? :D
-
Just realized it's a lot like this game: http://www.addictinggames.com/arcade-games/find-exit-game.jsp
Maybe try porting it? :D
I just made it through 10 levels of that, and I'd love to see it on the calc. That's an awesome game. :D
-
Actually Light kinda reminds me of Builderboy's Nightmare game now. I wonder if a calc port of nightmare would be possible?
By the way I wonder where has Michael_Lee been recently? ???
-
I wonder if this engine could be used for a pseudo-3D game... When I look at the screenshots I think GTA.
I'm afraid that currently, my engine is too slow for much of anything.
I've optimized it as much as I know how, but it's too slow inherently: I'm probably going to have to redo most of it.
Just realized it's a lot like this game: http://www.addictinggames.com/arcade-games/find-exit-game.jsp
Maybe try porting it? :D
I'm behind a filter: what's the game like?
Is there an equivalent version for android phones floating around?
Is there a youtube video somewhere?
-
It's similar in that when you're in a maze, and when you move, you "light up" the path in open directions.