Author Topic: Re: Hello everyone :)  (Read 28151 times)

0 Members and 1 Guest are viewing this topic.

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #20 on: December 02, 2008 »
you're welcome :)

32 is the bits per pixel value and 2 is the number of workpages to work with. I'm not sure so wait for a confirmation but afaik, the bits per pixel value is the memory you'll have to store each pixel color. The workpages are useful to avoid flickering. I'm pretty sure they have a lot of other goals but I don't know them. The screen you're writing/drawing on is one workpage.

Quote
how can i change the text position? from top to put it to the bottom of the screen and make it go from right to left.

Well, to move the text from LEFT to RIGHT, we moved the x value of the text. So to move it from TOP to BOTTOM, what is the value you'll change ?

a clue :
Code: [Select]
Draw String(X,Y),"your text"
:)

* bikerboy after experimenting a bit with the code  :stirrer:

the correct one is

Code: [Select]
Draw String(xText,470),"Hello World !!"
and to make the string go backwards? , also here's the code i used so far, what am i doing wrong and the moving text is not visible on the image? ::)

Code: [Select]
'' 0) init graphics
Screenres 640,480,32,2

'' 1) Create a pointer
Dim as any ptr MyImage

'' 2) Allocate memory
MyImage = imageCreate(640, 480)

'' 3) Load your image
Bload "1.bmp", MyImage

'' And then, you can put that image on screen with the.. "put" command :D

'' 4) Draw the image on screen
Put (0,0),MyImage   

Draw String(100,100),"This Is An Image Loader Test !"
Draw String(250,250),"And This Is The Text On Screen !"
Draw String(80,350),"Thank You Guys For All The help You're Giving Me With Coding !"
Draw String(0,1),"Y"
Draw String(0,20),"A"
Draw String(0,40),"Y"
Draw String(0,60),"!"
Draw String(0,80),"I"
Draw String(0,100),"t"
Draw String(0,120),"W"
Draw String(0,140),"o"
Draw String(0,160),"r"
Draw String(0,180),"k"
Draw String(0,200),"s"
Draw String(0,220),"!"


Dim as single xText   '' a variable to keep our x position

Do     '' Start of a loop. If you don't know it, look on fb's help, it's easy to understand :)
   
    Cls  '' clears the screen
   
    Draw String(xText,470),"Hello World !!"   '' draws the string ...

    xText+= 0.5   '' increment the value of xText

    Sleep 2,0  '' a little pause on each frame (try commenting it, you'll understand why it's needed :) )

Loop until xText>640     '' End of the previously started loop IF and ONLY IF x>640
sleep


Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Hello everyone :)
« Reply #21 on: December 03, 2008 »
Well, to go onward, you added some units to the x value of the text position. So to go backward, what do you need to do the x value ? :)

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #22 on: December 03, 2008 »
Well, to go onward, you added some units to the x value of the text position. So to go backward, what do you need to do the x value ? :)

got it ;D , changed xText+= 0.5 to xText-= 0.5 :carrot:

but now it appeared at the left and the text didn't start from the right, and there is no y to change to make it start from the right ::)

also played a bit with the loop but it's not looping ,  i mean the text only shows up only 1 time.




Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Hello everyone :)
« Reply #23 on: December 03, 2008 »
You're on the right track :)

Quote
but now it appeared at the left and the text didn't start from the right

Well the left of screen x coordinate is 0 so we don't have to add anything to make it start to scroll from left, just adding or subtracting some values to it's x position.
Now if you want to make it start from the right, I'm pretty sure you know you have something to do with the way you're using X in Draw String(X,Y) (maybe adding some value to the x value in Draw string ?)

Quote
also played a bit with the loop but it's not looping ,  i mean the text only shows up only 1 time.
Pay attention, the loop doesn't loop what you see, but what's written between -Do- and -loop-. So if you write
Code: [Select]
Do
cls
Draw string(80-i,50),"right to leeeeft"
i-=.5
loop
, it will [on EACH frame] draw the string and substract 0.5 to i so if after 100 frames, you don't see nothing, that's normal, the instruction i-=.5 is repeated infinitely (i-=.5   <=>  i = i-0.5 ) so the text position maybe -500 or -1000, etc..Nothing says to the program to put the text on the right border if it pass the left border of screen :)

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #24 on: December 03, 2008 »
experimented a bit with the i thingie and also experimented adding values to the draw string, all i managed to get is errors  ::)

but i managed to add 3 lines of text and make them move forwards and backwards :P

EDIT: i'm also having trouble loading the .bmp and making the moving text visible at the same time, all it show up is a black screen, or just the .bmp but no moving text
::) :skint:

« Last Edit: December 03, 2008 by bikerboy »


Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Hello everyone :)
« Reply #25 on: December 03, 2008 »
It works fine for me :)


Quote
i'm also having trouble loading the .bmp and making the moving text visible at the same time, all it show up is a black screen, or just the .bmp but no moving text

In which order did you put stuff on screen (text can be hidden by the bmp !) ? And can you show the code with which you're experiencing problems ?

A last thing : Do you know the instruction IF-ELSE-END IF ? An example :

Code: [Select]
If a = 5
  draw string(0,0), "a = 5, ok"
else
  draw string(0,0), "a <> 5. Non OK"
end if

You see the point ? Now imagine you want to make the text to come back to x = 0 if x>640 (640 is the screen width). In other words, you want the text to be written at position x=0 if its position is > 640. Do you see how you could transform that sentence into a code ?

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #26 on: December 03, 2008 »
this is the code i use.

Code: [Select]
'' 0) init graphics
Screenres 640,480,32,2

'' 1) Create a pointer
Dim as any ptr MyImage

'' 2) Allocate memory
MyImage = imageCreate(640, 480)

'' 3) Load your image
Bload "snow.bmp", MyImage

'' And then, you can put that image on screen with the.. "put" command :D

'' 4) Draw the image on screen
Put (0,0),MyImage   

Dim as single xText   '' a variable to keep our x position

Do     '' Start of a loop. If you don't know it, look on fb's help, it's easy to understand :)
   
    Cls  '' clears the screen
   
    Draw String(xText,430),"Hello World !!"   '' draws the string ...

    xText-= 0.5   '' increment the value of xText

    Sleep 2,0  '' a little pause on each frame (try commenting it, you'll understand why it's needed :) )

Loop until xText>640     '' End of the previously started loop IF and ONLY IF x>640
sleep

i tried to change the order of the code and i either got just the text or just the image , never both.


Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Hello everyone :)
« Reply #27 on: December 04, 2008 »
you must put the image IN the loop :)

CLS is an instruction to clear the screen. In your code, you display the image, and then start a loop which contain a CLS instruction (so every frame, the screen is cleared). You must put the image after the CLS :)

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #28 on: December 04, 2008 »
i just did what you said, the image loaded ok but no text :-\ , also the image flashed all the time (dunno maybe it's just my pc).

the code


Code: [Select]
Screenres 640,480,32,2   

Dim as single xText   '' a variable to keep our x position

Do     '' Start of a loop. If you don't know it, look on fb's help, it's easy to understand :)
   
    Cls  '' clears the screen
   
    '' 1) Create a pointer
Dim as any ptr MyImage
    '' 2) Allocate memory
MyImage = imageCreate(640, 480)

'' 3) Load your image
Bload "snow.bmp", MyImage
'' 4) Draw the image on screen
Put (0,0),MyImage
   
    Draw String(xText,430),"Hello World !!"   '' draws the string ...

    xText-= 0.5   '' increment the value of xText

    Sleep 2,0  '' a little pause on each frame (try commenting it, you'll understand why it's needed :) )

Loop until xText>640     '' End of the previously started loop IF and ONLY IF x>640
sleep


Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Hello everyone :)
« Reply #29 on: December 04, 2008 »
@bikerboy - have you tried moving the cls before the do loop - I *think* that is why the screen flashes?

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #30 on: December 04, 2008 »
@bikerboy - have you tried moving the cls before the do loop - I *think* that is why the screen flashes?

DrewPee

just tried that, and it flashed even more ::)


Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Hello everyone :)
« Reply #31 on: December 04, 2008 »
Sorry! I am at work and didnt try it out! :(
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #32 on: December 04, 2008 »
Sorry! I am at work and didnt try it out! :(


no worries man ,it will work eventually somehow :stirrer: :P

i'll make it work even if i have to nuke the thingie lol :P :P


Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Hello everyone :)
« Reply #33 on: December 04, 2008 »
I have just downloaded and installed Freebasic on my PC here . . .

The reason it flashes is because you are re-drawing the image over the top of itself because the draw routine it is in the loop.
I guess it does need to be in the loop because otherwise the text will just overprint itself.
The text is appearing but is in white . . . and on a white background?

Code: [Select]
Screenres 640,480,32,2   
Dim as double xText 
Dim as any ptr MyImage
MyImage = imageCreate(640, 480)
Bload "snow.bmp", MyImage
Put (0,0),MyImage
xText=600
Do
    color 255,0
    Draw String(450,430),"Hello World !!"
    xText-= 1
    sleep 2,0
    if xText<20 then xText=600
Loop until xText=0
sleep

I hope this helps? It isn't right but . . . a step closer? Maybe?

Andy
« Last Edit: December 04, 2008 by DrewPee »
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #34 on: December 04, 2008 »
tried moving it outside the loop and i get errors.

it's not the image's fault, i also loaded a dark color image and it still wasn't visible


..... wait i got it it's not flashing ;D


Code: [Select]
'' 0) init graphics
Screenres 640,480,32,2   

Dim as single xText   '' a variable to keep our x position
   
    Cls  '' clears the screen
   
    '' 1) Create a pointer
Dim as any ptr MyImage
    '' 2) Allocate memory
MyImage = imageCreate(640, 480)

'' 3) Load your image
Bload "snow.bmp", MyImage
'' 4) Draw the image on screen
Put (0,0),MyImage
  Do     '' Start of a loop. If you don't know it, look on fb's help, it's easy to understand :) 
    Draw String(xText,430),"Hello World !!"   '' draws the string ...

    xText-= 0.5   '' increment the value of xText

    Sleep 2,0  '' a little pause on each frame (try commenting it, you'll understand why it's needed :) )

Loop until xText>640     '' End of the previously started loop IF and ONLY IF x>640
sleep


Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Hello everyone :)
« Reply #35 on: December 04, 2008 »
Since you're always drawing directly onto your screen, you can see all updates (clearing & repainting) as flickering.
What you want to do instead is drawing to a hidden buffer and display it when painting is done.
Just create two display buffers (you've already done that!) and flip between the two buffer every frame.

So just initialize your stuff as you did before:
Code: [Select]
' set screen
Screenres 640,480,32,2

' initially place text-position to right border
Dim as single xText= 640

' load image (only once!)
Dim as any ptr MyImage
MyImage = imageCreate(640, 480)
Bload "snow.bmp", MyImage

Now get an additional variable to remember which buffer you're currently working on:
Code: [Select]
dim as integer buffer= 1
And swap the buffer after each iteration of your loop:
Code: [Select]
Do
    ' waits for vertical refresh:
    ScreenSync         

    ' set working and display buffer:
    ScreenSet buffer, buffer xor 1

    ' draw your stuff:
    cls
    Put (0,0),MyImage
    Draw String(xText,430),"Hello World !!"
    xText-= 1

    ' swap buffers:
    ' if buffer was '1' set it to '0',
    ' if buffer was '0' set it to '1'
    buffer= buffer xor 1
Loop until xText<0
« Last Edit: December 04, 2008 by hellfire »
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 563
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Hello everyone :)
« Reply #36 on: December 04, 2008 »
Nice one hellfire! :)
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #37 on: December 04, 2008 »
thanx hellfire but it still flickers

i tried this instead and it's ok, except that instead of text you can see a constant white line ???

Code: [Select]
'' 0) init graphics
Screenres 640,480,32,2   

Dim as single xText   '' a variable to keep our x position
   
    Cls  '' clears the screen
   
    '' 1) Create a pointer
Dim as any ptr MyImage
    '' 2) Allocate memory
MyImage = imageCreate(640, 480)

'' 3) Load your image
Bload "snow.bmp", MyImage
'' 4) Draw the image on screen
Put (0,0),MyImage
  Do     '' Start of a loop. If you don't know it, look on fb's help, it's easy to understand :) 
    Draw String(xText,40),"Hello World !!"   '' draws the string ...

    xText+= 0.5   '' increment the value of xText

    Sleep 2,0  '' a little pause on each frame (try commenting it, you'll understand why it's needed :) )

Loop until xText>640     '' End of the previously started loop IF and ONLY IF x>640
sleep

the weird thing is that when i run it in FBIde it shows this white line instead of text, when i make it an .exe file it shows no text or white line at all :-\

i think my freebasic version is possesed or something lol :P




Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: Hello everyone :)
« Reply #38 on: December 04, 2008 »
Quote
thanx hellfire but it still flickers
No, it doesn't:
Code: [Select]
Screenres 640,480,32,2   
Dim as any ptr MyImage
MyImage = imageCreate(640, 480)
Bload "snow.bmp", MyImage

dim as single xText= 0
dim as integer buffer= 1

Do
    ScreenSync         
    ScreenSet buffer, buffer xor 1
    cls
    Put (0,0),MyImage
    Draw String(xText,40),"Hello World !!"
    xText+= 0.5
    buffer= buffer xor 1
    Sleep 2,0
Loop until xText>640
sleep

Quote
instead of text you can see a constant white line
Code: [Select]
Do
    Draw String(xText,40),"Hello World !!"
    xText+= 0.5
Loop until xText>640
You're not removing the old text.

Quote
when i make it an .exe file it shows no text or white line at all
Initialize your variables. In your code xText can have any value.
« Last Edit: December 04, 2008 by hellfire »
Challenge Trophies Won:

Offline bikerboy

  • Amiga 1200
  • ****
  • Posts: 349
  • Karma: 12
    • View Profile
Re: Hello everyone :)
« Reply #39 on: December 04, 2008 »
what you quoted was the old code i was using ;)

honestly i used the one you said before and it flickered ??? , now it plays as smoothy as it can be ::) , definitely my FBIde is posessed :stirrer:

the code i used now


Code: [Select]
' load image (only once!)
Dim as any ptr MyImage
MyImage = imageCreate(640, 480)
Bload "snow.bmp", MyImage

dim as integer buffer= 1

Do
    ' waits for vertical refresh:
    ScreenSync         

    ' set working and display buffer:
    ScreenSet buffer, buffer xor 1

    ' draw your stuff:
    cls
    Put (0,0),MyImage
    Draw String(xText,470),"Hello guys !! ... thank you for everything !! .... your help is priceless !! couldn't have done what you see before you without you guys :) ... "
    xText-= 1

    ' swap buffers:
    ' if buffer was '1' set it to '0',
    ' if buffer was '0' set it to '1'
    buffer= buffer xor 1
Loop until xText<0
sleep

.exe attached

but now another problem arised ::) , i wrote a little something and it shows just fine but after a while the text freezes up :-\

can't thank you enough guys for all your help :clap: