Author Topic: Sinewave Help Please  (Read 6159 times)

0 Members and 1 Guest are viewing this topic.

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Sinewave Help Please
« on: September 11, 2011 »
Hi, I was wondering if some one could help me with this problem I have?
I have a routine that Shockwave knocked up for me to draw a sinewave scroller.
It works great but now I would like to make some changes to it and as maths is not
my strong point I once again find my self stuck again!

I have been trying to get the sinewave to randomly change like on some of the old
Amiga demos Amplitude change and so on, god this is hard to explain  :-[
Here is my code for the scroller.

Function Do_Scroller()
   
   ScrlPos:+2
   
   If ScrlPos > 16 Then
      ScrlPos:-16
      Textpos:+1
      If Textpos > Len(ScrollText) - 52 Textpos = 1
   End If
   
   Local DrawPos:Int
   Local TextAdd:Int
   Local Letters:Int
   
   TextAdd = 0
   DrawPos = (-16) - ScrlPos
      
    Repeat
      Letters = (Asc(Mid(ScrollText, (Textpos + TextAdd), 1)) - 32) * 16
      For Local IL:Int = 0 To 15
         DrawImage Font, DrawPos + IL, 300 + (70 * Sin(Sineadd + DrawPos + IL)), Letters + IL
      Next
      TextAdd:+1
      DrawPos:+16
   Until DrawPos >= xRes
   
End Function

Thanks for any help.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Sinewave Help Please
« Reply #1 on: September 11, 2011 »
Trying changing the value of "Sineadd" each time Do_Scroller is called.

Increase or decrease its value by 1 each time. That may help.
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Sinewave Help Please
« Reply #2 on: September 12, 2011 »
If only it was that simple, I had tried that and what ever value I make it the sine remains the same.
It must be the way the Sin() function is setup, I was wondering if there was a different way so it would
be more manageable.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Sinewave Help Please
« Reply #3 on: September 12, 2011 »
Pot Noodle, which language is this, blitz?  If so, I'm just curious why you don't use Freebasic/Purebasic?
raizor

Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Sinewave Help Please
« Reply #4 on: September 12, 2011 »
Pot Noodle, which language is this, blitz?  If so, I'm just curious why you don't use Freebasic/Purebasic?
:clap:
Challenge Trophies Won:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: Sinewave Help Please
« Reply #5 on: September 12, 2011 »
Quote
Pot Noodle, which language is this, blitz?  If so, I'm just curious why you don't use Freebasic/Purebasic?

Well, The Freebasic/Purebasic had smaller Files size than Blitz Max(Correct me if I am wrong) as far as I know but end of day....it down to the person who are Comfortable with the programming Language(if he happy with BlitzMax then so be it  :clap:)

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Sinewave Help Please
« Reply #6 on: September 12, 2011 »
Quote
Pot Noodle, which language is this, blitz?  If so, I'm just curious why you don't use Freebasic/Purebasic?

Well, The Freebasic/Purebasic had smaller Files size than Blitz Max(Correct me if I am wrong) as far as I know but end of day....it down to the person who are Comfortable with the programming Language(if he happy with BlitzMax then so be it  :clap:)

Hehe, I'm just curious, that's all :) 
raizor

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17397
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Sinewave Help Please
« Reply #7 on: September 12, 2011 »
   DrawImage Font, DrawPos + IL, 300 + (70 * Sin(Sineadd + DrawPos + IL)), Letters + IL

The number in red is the amplitude.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Sinewave Help Please
« Reply #8 on: September 12, 2011 »
Thanks Shockwave I did try that, must be me then, But Raizor can you tell me the gain I would have using PureBasic
or FreeBasic and to witch one would you use? if you were using Blitzmax.
Pros & Cons would be nice, I am willing to be converted and you are going to wish you never asked me that!  ;D


Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Sinewave Help Please
« Reply #9 on: September 12, 2011 »
Thanks Shockwave I did try that, must be me then, But Raizor can you tell me the gain I would have using PureBasic
or FreeBasic and to witch one would you use? if you were using Blitzmax.
Pros & Cons would be nice, I am willing to be converted and you are going to wish you never asked me that!  ;D

I just think it would probably make life easier for you as there seem to be a lot more people here who use freebasic and purebasic. I'm starting to play with freebasic a bit, so I can probably help with things in future. I'm certainly not trying to convert you, I was just curious as to why you chose blitz :)
raizor

Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Sinewave Help Please
« Reply #10 on: September 12, 2011 »
No problem, But you do realize what you have done don't you?
is there more PureBasic users than DarkBasic user's?, I have just had a look at them both "Dammit You Got Me Thinking"
If anyone has preference over these two please let me know, Thanks Raizor.

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: Sinewave Help Please
« Reply #11 on: September 12, 2011 »
Purebasic is Much better than Darkbasic!! But end of the day...It down to you on what you are Comfortable with the programming Language...

The Purebasic users on here are

padman
energy
jace_stknights
Raizor (He going have try on freebasic to see if he like it)
Vain   (He used purebasic before but I dont know what Programming language he using...maybe c#)

Freebasic User

Shockwave
relsoft
rbz
Storm Trooper
rdc

I cant think of anymore but make own Choice  ;D



« Last Edit: September 13, 2011 by Hotshot »

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Sinewave Help Please
« Reply #12 on: September 13, 2011 »
... But Raizor can you tell me the gain I would have using PureBasic
or FreeBasic and to witch one would you use? if you were using Blitzmax.
Pros & Cons would be nice, I am willing to be converted and you are going to wish you never asked me that!  ;D
IMO, you can do wonders with Blitzmax, just seeing things done with it on the blitz website.
Just try to learn as much as you can about it, and then you can try another compiler and see which one suits better to you.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Sinewave Help Please
« Reply #13 on: September 13, 2011 »
Changing languages ain't gonna fix the problem..!  For the record, I'm a C/C++/C# man, I use the original BlitzBasic to do rapid prototyping, and I've been known to dabble in FreeBasic.

V = A * sin(F)

A is the amplitude, F is the frequency.  If you want larger waves, increase A.  If you want the wiggles to be closer together, increase the increments of F.

Jim
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Sinewave Help Please
« Reply #14 on: September 13, 2011 »
http://www.dbfinteractive.com/forum/index.php?topic=5357.0

This topic speaks about Sinescroll, with examples in Purebasic...
Challenge Trophies Won:

Offline Pot Noodle

  • Sponsor
  • Amiga 1200
  • *******
  • Posts: 271
  • Karma: 15
  • Computers have lots of memory but no imagination
    • View Profile
Re: Sinewave Help Please
« Reply #15 on: September 13, 2011 »
Thanks Jim, I finally got the answer I was after  :goodpost: and thanks to you all for  the info on other languages.