Author Topic: Lightning!  (Read 8163 times)

0 Members and 1 Guest are viewing this topic.

Offline Gale

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +1/-0
  • Ti-84+ Silver Edition
    • View Profile
Lightning!
« 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:

Code: [Select]
: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.
remember me as a time of day...

SirCmpwn

  • Guest
Re: Lightning!
« Reply #1 on: March 25, 2010, 07:11:08 pm »
Have you considered using assembly libraries?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Lightning!
« Reply #2 on: March 25, 2010, 07:14:03 pm »
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)
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

SirCmpwn

  • Guest
Re: Lightning!
« Reply #3 on: March 25, 2010, 07:26:43 pm »
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.

Offline Gale

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +1/-0
  • Ti-84+ Silver Edition
    • View Profile
Re: Lightning!
« Reply #4 on: March 25, 2010, 07:29:54 pm »
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:
remember me as a time of day...

SirCmpwn

  • Guest
Re: Lightning!
« Reply #5 on: March 25, 2010, 07:33:07 pm »
Lol, good idea.
I would strongly reccomend using xLib or Celtic III, though.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Lightning!
« Reply #6 on: March 25, 2010, 07:40:57 pm »
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:

Code: [Select]
For(A,1,5
For(B,1,3
real(3,B,0,1
RandRandRandRand
End
End
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6265
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Lightning!
« Reply #7 on: March 25, 2010, 07:52:10 pm »
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.
/e

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Lightning!
« Reply #8 on: March 25, 2010, 08:11:29 pm »
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 :)

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Lightning!
« Reply #9 on: March 25, 2010, 11:01:13 pm »
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
Although it might be slower than hard-coding (which means coding each PtOn( Codes) because this method is going through the For( loop.
« Last Edit: March 25, 2010, 11:06:20 pm by jsj795 »


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline {AP}

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 981
  • Rating: +74/-3
  • I am Webmaster!
    • View Profile
    • Removed From Game
Re: Lightning!
« Reply #10 on: March 25, 2010, 11:04:42 pm »
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

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Lightning!
« Reply #11 on: March 25, 2010, 11:06:18 pm »
^
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Lightning!
« Reply #12 on: March 25, 2010, 11:06:41 pm »
oh okay nvm then^^


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Lightning!
« Reply #13 on: March 25, 2010, 11:26:47 pm »
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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Lightning!
« Reply #14 on: March 25, 2010, 11:30:18 pm »
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.
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)