Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: Gale on March 25, 2010, 07:09:57 pm
-
Hey! I'm currently working on my first RPG in pure BASIC.
For the main menu, i want to have lightning strikes on the horizon in the picture on the backdrop. So far, this is my code:
:Lbl M1
:RecallPic Pic3
:While 1
:rand(25
:RecallPic Pic5
:rand(25
:ClrDraw
:RecallPic Pic3
:End
Pic3 is the normal picture, and Pic5 is the normal picture, but with lightning bolts in the picture. My problem is this: the ClrDraw causes the whole picture to flicker, and i don't know how to avoid it. And yes, I know the flickering can be interpreted as lightning strikes, but i still don't like it.
-
Have you considered using assembly libraries?
-
unfortunately it is impossible to prevent the flicker without the help of ASM (specifically Zpic, since it overwrites the entire screen instead of just turning on pixels needed and leave the rest intact). The only way to really prevent it without the help of ASM is to not use pics to draw the bolts, but simply draw them manually with lines(). For example, if your background is black you'll use Line(x1,y1,x2,y2,0 to draw parts of them, and Line(x1,y1,x2,y2 when erasing the bolts. This may be slower, though. (altough it will take much less memory)
-
If the scene takes place at night, I would suggest storing a picture of a black screen. Then, you can clear the screen with black and get rid of the lightning fairly easily.
-
yeahh, but i wanted the bolts to look really jagged, and it would call for pt-on() commands and other annoying things. i guess i'll just have to trick my friends and say the flicker is intentional P:
-
Lol, good idea.
I would strongly reccomend using xLib or Celtic III, though.
-
if you use xlib/celtic, make sure to add a few Rand commands between each frames, though, else it will run way too fast and you won't see anything.
For example, if you loop through 3 pics 5 times, do:
For(A,1,5
For(B,1,3
real(3,B,0,1
RandRandRandRand
End
End
-
instead of rand's you could use a randInt(0,9,2 to slow it down and just play around with the numbers to find the right setting.
-
I use rand(# to do all of my delays, you just change the number higher to make a longer delay. Rand(#) generates a list of length # filled with random elements, so it can be quite slow :)
-
For example, if your background is black you'll use Line(x1,y1,x2,y2,0 to draw parts of them, and Line(x1,y1,x2,y2 when erasing the bolts.
Isn't it backwards? Line(x1,y1,x2,y2 is to draw and Line(x1,y1,x2,y2,0 to erase.
And I tend to switch back and forth with rand(X and For(X,0,99:End for delay effect. I found out that if x is really big in rand(x, it might cause memory error (such as insufficient ram if you are running big program) since you are storing the list with the dimension of x into Ans
Edit: If there are too many PtOn( then you can use the compression, which can be found here:
http://tibasicdev.wikidot.com/compression (http://tibasicdev.wikidot.com/compression)
Although it might be slower than hard-coding (which means coding each PtOn( Codes) because this method is going through the For( loop.
-
Isn't it backwards? Line(x1,y1,x2,y2 is to draw and Line(x1,y1,x2,y2,0 to erase.
Normally, yes, but he said that he's on a black background. ;P
-
^
-
oh okay nvm then^^
-
Mmmm if you wanted to stick to pure Basic you could also draw the lightning with Line(#,#,#,#,0) and then erase it with a recallPic, since recallPic does not overwrite, it just overlays. You could even generate the pic yourself in startup if you wanted to be file independent.
-
keep in mind with this method, some bolts will appear later, though. If you use this, you might want to display the top of each lightnings first, then the middle part, then the bottom, etc.
-
Yeah, and that could also give a nice effect too!
-
what real(# would i use from xLIB or Celtic? and i would use lines, but i'm trying to keep program size to an absolute minimum, as the game itself will take a lot of mem (it's gonna be a moving sprite rpg with one or two detailed towns)
-
You'd use real(3 most likely. It works exactly like RecallPic but with some other features.
real(3,pic_num,logic,update_LCD
pic_num = Number of the pic. (0-255)
logic = How the pic is displayed.
0 = Overwrite
1 = AND
2 = OR
3 = XOR
update_LCD =
0. Doesn't update
1. Updates screen
For what you want, you'd just need "real(3,3,0,1" and "real(3,5,0,1".
Also, note that a Pic takes up a LOT of memory so it would probably be smaller to use several line commands over a 2nd picture.
Of course, if you plan on using xLIB or CIII anyway, the pics can be archived so it will take less RAM to use pics.
Up to you.
-
hmm. well i have everything archived all the time anyway (i use CalcUtil). but yeah, i mostly cared about RAM because my friend has a normal TI-84, and almost all of his arc and ram are in use, and since he's doing the storyline, he should be able to use it P:
-
^CalcUtil++
-
^CalcUtil++
haha best app i've ever found besides omnicalc ^^
-
We are a bit offtopic, but I am curious about something: Do you mean calcutil runs every single archived program on your calc in any way? I mean for example, if I have
EXEC EDIT NEW
*LOL
*PRGMLOL
*ZLOL
ZSPRITE
*ZZZ
prgmLOL contains:
:A+1->A
:prgmZZZ
:prgmZLOL
Will prgmZZZ/ZLOL commands return a ERR:ARCHIVED?
Back on topic, I personally would prefer using lines for drawing lightning, simply because pics are a waste of space (unless the bolts are really complex and stuff).
-
nope, i'm pretty sure it wont. pictures cant be archived though. to run archived pics you can just use xLIB anyway
so yeahh, now i can clear my ram pretty haphazardly and have around 19-20k RAM at all times P:
-
aaah ok I see now. I was wondering cuz I was unsure to which extent CalcUtil worked with archived stuff. But yeah my point is that even if archived the pics still took a lot of memory x.x. I mean, in ROL3, if I decided to draw the lightning bolt inside a pic instead of an archived subroutine, I would have ran out of pic, first, (ones that can be sent fine ungrouped, that is), and secondly I would have wasted about 500 bytes of archive
I guess it's up to you, though, but remember you can't just use pics for every single thing in the programming world. Sometimes it's best to either draw stuff manually to save space, abuse programs to run archived subprograms like XCOPY or xLIB (if you use it alerady) or use smaller sprites. It depends of opinions, though. I just had bad memories of downloading games abusing pictures before, only to realise the abuse of pics made them so huge that the author could only add maybe 4 or 5 map in the game
-
one word about calcutil its very glitchy with omnicalc and a few other asm programs :/
i had to reset my os cause if it X.x so be sure to backup often X,x
-
wasn't the code also stolen from NoShell, but with more functions added? I wonder if it works on OS 2.5xMP too
-
i wouldn't doubt that it was stolen from NoShell, it's almost identical haha
-
BrandonW said it was. Idk if the author of calcutil asked permission, but BrandonW said he didn't mind since Noshell isn't really updated anymore and buggy
-
The calcUtil credits refer to NoShell and Brandon iirc.
-
aaah ok, that's good at least :P
-
^^ Works w/2.53mp
@Geekboy1011 it really screwed up your OS?
-
Gale, I'm glad you're working on an RPG! This will be pretty cool!
How's progress? ;D