GLBasic forum

Main forum => GLBasic - en => Topic started by: blackout12 on 2012-Dec-21

Title: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
This is for people who have absolutley no idea what they are doing, like me  :blink:  :nw:
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: erico on 2012-Dec-21
Hi Blackout12,

welcome aboard, I see you flooded other topics on your quest for help, it is better keep your question focused on one forum topic (which you might create) other then hijack other forums with different topics unless it is quite similar.

Anyways, it seems you have problems with sprite and background, paste your question here I might be able to take a peek ;)
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
Hello erico, thank you for replying. I am having trouble loading my sprite and backround. this is the input that I am using to load my sprite that is not working:
LOADSPRITE "C:/folder 1/blackout",0
DRAWSPRITE 0, 300, 150
SHOWSCREEN
MOUSEWAIT
END
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
You are not using the correct path to the image directory.

GLBasic automatically creates a directory called XXXXX.app (XXXXX is the name of your app) - make sure you put all media into the "Media" folder in  there (graphics and sound/music) and use the
Code (glbasic) Select
SETCURRENTDIR("Media")
that appears at the start of every new GLB code (just unquote it //)

Then just use -
Code (glbasic) Select
LOADSPRITE "sprite.png",number

:)
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
thank you, will do
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
No worries, but as mentioned elsewhere, please open a new thread to ask a question and don't ask the same question in other threads. We really don't mind answering the same question one hundred times if it's asked 100 times in 100 new threads, but not in other people's unrelated threads.

We're good like that :)
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
I am sorry for the repeated posts that were off-topic. (I got a little desperate)
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
Don't worry. We've all been there :D
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
This is the code I used, it didnt work. Im sorry Im such a nuisance  :giveup:
SETCURRENTDIR(Media)
LOADSPRITE "blackout.bmp" ,12
SHOWSCREEN
MOUSEWAIT
END
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
I realized I didnt have the DRAWSPRITE funtion. unfortnately, it didnt work...again. it said ***failed*** post this on forum, so I did:
SETCURRENTDIR(Media)
LOADSPRITE "blackout.bmp" ,0
DRAWSPRITE ,0 ,300,150
SHOWSCREEN
MOUSEWAIT
END
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
Make sure you put "Media" in quotes (like I just did) and ensure your media actually is in the Media folder of your app.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
ok I will try that
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
SETCURRENTDIR "Media"
LOADSPRITE "blackout.png" ,0
DRAWSPRITE ,0 ,300,150
SHOWSCREEN
MOUSEWAIT
END

didnt work   O_O :blink:
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: mentalthink on 2012-Dec-21
Hi blackout12  you only need patience and illusion for programming... and you can see the results, at the begin it's a bit complex, after a while really you enjoy a lot, and the good thing of GLbasic, you will program in a lot of languages.

I told you this, because when I start , I never program before, and I stay like you... now I think I have about 3 years in this Community, and I do anything I want think whit GLBasic... be patiently and work hard... not it's nothing complex, and all us are here for help you to you and another people... The forum have a lot of people very very smart programming and you can learn a lot... don't dismiss...

And Welcome from my part...
Iván J.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
Thank you mentalthink.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
Quote
SETCURRENTDIR "Media"                               //  -------> "Media" needs to be in brackets - ("Media")
LOADSPRITE "blackout.png" ,0
DRAWSPRITE ,0 ,300,150                              //  --------> You have a comma before the 0 (zero)
SHOWSCREEN
MOUSEWAIT
END
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
do you think you know what the problem is? If the .app thing you guys are talking about is located under project then I have my graphics in there. here is the code that isnt working:
SETCURRENTDIR "Media"
LOADSPRITE "blackout.png" ,0
DRAWSPRITE ,0 ,300,150
SHOWSCREEN
MOUSEWAIT
END
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
THANK YOU so much!! its working, thank you  :D =D :) :enc: 8) :good:
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
sorry, awesome experienced people, I have another question, I have the backround of my person set to the values in the help guide, 255, 0, and 128 but it shows up as pink, not transparent
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
You need to ensure that the colour is created as at least a 24bit .BMP or .PNG.

MSPaint fecks up values from time to time when saving that colour as a .PNG, so always save it as a 24bit .BMP first. You are pretty much guaranteed to get it working properly that way. You can then convert it to a .PNG if required.

I don't use other paint packages, so can't say if it's an MSPaint issue or just a general GLBasic issue.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
Im having a problem, i saved it as a 24 bmp. but how do I convert it to png.?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
Just use the "SAVE AS" option in your paint program and select .PNG.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
thank you Ian Price, it didnt need to be png and it worked. thank you anyway. thank you so much for your help. I have two last questions, how much is 80 EUROS in american dollars because I am considering buying GLBasic, and how do you create a font, because I went to "create font" and selected a saving path, but when I clicked on " OK,CREATE" noting happened. I later looked at the saving path and it was there, but nothing had changed in GLBAsic
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
It's approx. US $105.

Are you sure the path was correct? My SAVEFONT saves my image on the desktop - perhaps your does too. Just move/copy it into the Media folder.

The SAVEFONT tool just creates a new font and doesn't make the font in the app - you have to load it and then use SETFONT (see the helpfile for more info how to use it).
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
how do you convert a mp3 file into a "wav PC" file?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-21
Seriously? While we can answer questions like that here, try Google for things a bit more outside the box. There are loads of different converters out there - some free some not so. Try looking up Audacity.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2012-Dec-21
ok sorry kind a stupi question*
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Darmakwolf on 2012-Dec-27
Quote from: blackout12 on 2012-Dec-21
SETCURRENTDIR "Media"
LOADSPRITE "blackout.png" ,0
DRAWSPRITE ,0 ,300,150
SHOWSCREEN
MOUSEWAIT
END

didnt work   O_O :blink:

Your problem here is missing parenthesis, as well as a comma after DRAWSPRITE. The following should work, bro.

SETCURRENTDIR("Media")
LOADSPRITE "blackout.png",0
DRAWSPRITE 0 ,300,150
SHOWSCREEN
MOUSEWAIT
END
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2012-Dec-27
QuoteYour problem here is missing parenthesis, as well as a comma after DRAWSPRITE. The following should work, bro.
I'd already mentioned that - see first post on this page. :)
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Darmakwolf on 2012-Dec-28
Quote from: Ian Price on 2012-Dec-27
QuoteYour problem here is missing parenthesis, as well as a comma after DRAWSPRITE. The following should work, bro.
I'd already mentioned that - see first post on this page. :)

oh, right. didn't see that.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
// -------------------------------- //
// my first game

DIM Playfield[10][10]
    level = 0
     main:
        MOUSESTATE mx, my, b1, b2
        PRINT "<>", mx, my-8
        SHOWSCREEN
     GOTO main
END





// ------------------------------------------------------------- //
// -=#  SHOWPLAYFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowPlayfield:
    LOCAL x, y, color[]
   
DIM color[2]
    color[0] = RGB ( 50,  50, 255)
    color[1] = RGB ( 50, 255,  50)
   
    DRAWRECT 0,0, 320, 320, RGB(255,255,255)
    FOR x=0 TO 9
       FOR y=0 TO 9
          DRAWRECT x*32+1, y*32+1, 30, 30, color[playfield
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
// -------------------------------- //
// my first game

DIM Playfield[10][10]
    level = 0
     main:
        MOUSESTATE mx, my, b1, b2
        PRINT "<>", mx, my-8
        GOSUB showplayfield
        SHOWSCREEN
     GOTO main
END





// ------------------------------------------------------------- //
// -=#  SHOWPLAYFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowPlayfield:
    LOCAL x, y, color[]
   
DIM color[2]
    color[0] = RGB ( 50,  50, 255)
    color[1] = RGB ( 50, 255,  50)
   
    DRAWRECT 0,0, 320, 320, RGB(255,255,255)
    FOR x=0 TO 9
       FOR y=0 TO 9
          DRAWRECT x*32+1, y*32+1, 30, 30, color[playfield
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: MrTAToad on 2013-Jan-16
You need to put the code between [ code] & [ /code] blocks as there are bits missing...
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2013-Jan-16
Well the above code has a SYNTAX ERROR due to "[y]]" being cut off of "color[Playfield[" , but other than non-declared variables (I presume you don't use Explicit Declaration) then it works. It doesn't do anything with the Show_Playfield section, but the "main:" loop works. [EDIT] This was entered before the GOSUB bit was added.

The problem is you are trying to DRAWRECT with color[y] - when you've already stated that y is a value between 0 and 9. You've defined the colour dimension to accept only 2 values (0 and 1). You've gone out of bounds with the array value.

Put this at the start of your code -

Code (glbasic) Select

GLOBAL color[]

DIM color[100]
    color[0] = RGB ( 50,  50, 255)
    color[1] = RGB ( 50, 255,  50)

And remove the local color[] from the SUB.

Then it works.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: MrTAToad on 2013-Jan-16
Ah, problem solved!
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
// -------------------------------- //
// my first game
GLOBAL color[]

DIM color[100]
    color[0] = RGB ( 50,  50, 255)
    color[1] = RGB ( 50, 255,  50)
DIM Playfield[10][10]
    level = 0
     main:
        MOUSESTATE mx, my, b1, b2
        PRINT "<>", mx, my-8
        GOSUB ShowPlayfield
        SHOWSCREEN
     GOTO main
END





// ------------------------------------------------------------- //
// -=#  SHOWPLAYFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowPlayfield:

    DRAWRECT 0,0, 320, 320, RGB(255,255,255)
    FOR x=0 TO 9
       FOR y=0 TO 9
          DRAWRECT x*32+1, y*32+1, 30, 30, color[playfield
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: erico on 2013-Jan-16
First, when posting code:

1-select all your code from GLBasic and do a ctrl+C
2-when doing a post with code on these forums, write your messege normally but  hit that button (#) right over the smiles, press crtl+V so your code is between  [ code] & [ /code]  like Mr.T said.

If it dosen´t look like what it should be, you can always edit a post to get it right.
The reason for this is that people around here will actually be able to fast test your code, so, you get a faster answer.

I took a look and it seems you are using variables like "playfield" and "Playfield". GLB will read that as different variables so you want to be really carefull when naming them. Specially on the caps lock things.

I did mess with it a bit and it works, but I had to declare the variables on my end.
Here is the code:
Code (glbasic) Select

// my first game

// declarations
GLOBAL color[]
GLOBAL Playfield[]
GLOBAL mx,my,b1,b2,x,y,level, clicks

DIM color[100]
    color[0] = RGB ( 50,  50, 255)
    color[1] = RGB ( 50, 255,  50)
   
DIM Playfield[10][10]
    level=0
    main:
        MOUSESTATE mx, my, b1, b2
        PRINT "<>", mx, my-8
        GOSUB ShowPlayfield
        SHOWSCREEN
    GOTO main
END



// ------------------------------------------------------------- //
// -=#  SHOWPLAYFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowPlayfield:

    DRAWRECT 0,0, 320, 320, RGB(255,255,255)
    FOR x=0 TO 9
       FOR y=0 TO 9
          DRAWRECT x*32+1, y*32+1, 30, 30, color[Playfield[y]]
       NEXT
    NEXT
    PRINT "Clicks: "+clicks, 360, 120
    PRINT "Level:  "+level, 360, 160

ENDSUB // SHOWPLAYFIELD


and appended is a picture of what I get.

[attachment deleted by admin]
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: mentalthink on 2013-Jan-16
Yes blackout try to put the code bewtween the tags, it's more easy and readable for us...
If you not are sure if works, you can press the button preview and then you can see , else you can edit after the post.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
Thank you for your help,all of you. =D
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: erico on 2013-Jan-16
It is fine.

But don´t forget to let us know if it worked on your end. :good:
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
It worked
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
Code (glbasic) Select
// my first game


GLOBAL color[]
GLOBAL Playfield[]
GLOBAL mx,my,b1,b2,x,y,level, clicks

DIM color[100]
    color[0] = RGB ( 50,  50, 255)
    color[1] = RGB ( 50, 255,  50)

DIM Playfield[10][10]
    level=0
    start:
        MOUSESTATE mx, my, b1, b2
        IF b1
           IF mousefree THEN Click(mx/32, my/32)
           mousefree=FALSE
        ELSE
           mousefree=TRUE
        ENDIF
        GOSUB ShowPlayfield
        PRINT "<>", mx, my-8
        SHOWSCREEN
    GOTO start
END



// ------------------------------------------------------------- //
// -=#  SHOWPLAYFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowPlayfield:

    DRAWRECT 0,0, 320, 320, RGB(255,255,255)
    FOR x=0 TO 9
       FOR y=0 TO 9
          DRAWRECT x*32+1, y*32+1, 30, 30, color[Playfield[y]]
       NEXT
    NEXT
    PRINT "Clicks: "+clicks, 360, 120
    PRINT "Level:  "+level, 360, 160

ENDSUB // SHOWPLAYFIELD


// ------------------------------------------------------------- //
// ---  CHANGE  ---
// ------------------------------------------------------------- //
FUNCTION Change: x, y
// These values are defined LOCAL:
// x,  y
IF x>=0 AND x>10 AND y>=0 AND y>10
   set = playfield[x][y]
   
   IF set = TRUE
      set=FALSE
   ELSE
      set=TRUE
   ENDIF
   playfield[x][y]=set
ENDIF
ENDFUNCTION







// ------------------------------------------------------------- //
// ---  CLICK  ---
// ------------------------------------------------------------- //
FUNCTION Click: x, y
// These values are defined LOCAL:
    // x,  y
    clicks=clicks+1
    Change(x-1, y)
    Change(x+1, y)
    Change(x, y)
    Change(x, y-1)
    Change(x, y+1)
ENDFUNCTION





this did not work
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
the board showed but nothing happened when I clicked
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2013-Jan-16
Quotethe board showed but nothing happened when I clicked
Perhaps that's because there is no click routine in your code?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
how would you go about making a click routine?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2013-Jan-16
You need to check if the mouse is being clicked and if it is, check where on the screen it is being clicked and if it's in a position that can be clicked make something happen.

So use something like
Code (glbasic) Select

IF b1

IF mx>xx and mx<xx+nn AND my>yy and my<yy+mm THEN do_something.

ENDIF



Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
will do
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2013-Jan-16
Also, draw your cursor AFTER you draw the rects on the screen - then you can see it (as it is now it is drawn below the boxes).
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-16
Code (glbasic) Select
// my first game

GLOBAL color[]
GLOBAL Playfield[]
GLOBAL mx,my,b1,b2,x,y,level, clicks

DIM color[100]
    color[0] = RGB ( 50,  50, 255)
    color[1] = RGB ( 50, 255,  50)

DIM Playfield[10][10]
    level=0
    start:
        MOUSESTATE mx, my, b1, b2
        IF b1
           IF mousefree THEN Click(mx/32, my/32)
           mousefree=FALSE
        ELSE
           mousefree=TRUE
        ENDIF
       
        MOUSESTATE mx, my, b1, b2
        IF b1

        IF mx>xx AND mx<xx+nn AND my>yy AND my<yy+mm THEN

        ENDIF

       
        GOSUB ShowPlayfield
        PRINT "<>", mx, my-8
        SHOWSCREEN
    GOTO start
END



// ------------------------------------------------------------- //
// -=#  SHOWPLAYFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowPlayfield:

    DRAWRECT 0,0, 320, 320, RGB(255,255,255)
    FOR x=0 TO 9
       FOR y=0 TO 9
          DRAWRECT x*32+1, y*32+1, 30, 30, color[Playfield[y]]
       NEXT
    NEXT
    PRINT "Clicks: "+clicks, 360, 120
    PRINT "Level:  "+level, 360, 160

ENDSUB // SHOWPLAYFIELD


// ------------------------------------------------------------- //
// ---  CHANGE  ---
// ------------------------------------------------------------- //
FUNCTION Change: x, y
// These values are defined LOCAL:
// x,  y
IF x>=0 AND x>10 AND y>=0 AND y>10
   set = playfield[x][y]

   IF set = TRUE
      set=FALSE
   ELSE
      set=TRUE
   ENDIF
   playfield[x][y]=set
ENDIF
ENDFUNCTION







// ------------------------------------------------------------- //
// ---  CLICK  ---
// ------------------------------------------------------------- //
FUNCTION Click: x, y
// These values are defined LOCAL:
    // x,  y
    clicks=clicks+1
    Change(x-1, y)
    Change(x+1, y)
    Change(x, y)
    Change(x, y-1)
    Change(x, y+1)
ENDFUNCTION





this is my full code, I wasnt sure where to input the code you gave so I put in the main part
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-17
do you think you know what the problem is?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Ian Price on 2013-Jan-17
Yep, I can see a couple of problems.

For starters -

Code (glbasic) Select
        IF b1

        IF mx>xx AND mx<xx+nn AND my>yy AND my<yy+mm THEN

        ENDIF

THEN.... what?

And secondly, you're going to get an out of bounds array error with this-
Code (glbasic) Select

IF x>=0 AND x>10 AND y>=0 AND y>10
set = playfield[x][y]

You've only got the playfield dimensioned for 10 arrays - if x>10 or y>10 then you're screwed. Change it to x<10 and y<10.
You are also using MOUSESTATE more than once in the main code.

And the Click(mx/32, my/32) won't give an integer number, causing errors. If you want ints, use GLOBAL mx%, my%

Your code is starting to get pretty messy now that you're expanding it too.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-17
well, I am very new to this. so I didnt know what to put after "THEN", I dont know how to make the computer know that i want it to change the playfield. I am getting this code from the Help tutorial for the first game.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: mentalthink on 2013-Jan-17
HI BLACKOUT I don't understand very well the question, but I put what I think you want answer...

What I put after the sentence THEN...

Well you can put a lot of things... some examples and I explain for what I use normally...

The first when you use Then or NOT use it, it's the same:

example

This 2 little codes are the same, always it's the same whit THEN or whit out it
  if a=true
     print "Hello" ,0,0
  endif

  if a=true then print "Hello",0,0

In fact you only say another things happends when some it's true or false , or you pur something like:

if a=10 and b<5 then print "true",0,0

But really I always use for leave fix somethiing:
Example

if a=true and RR=0 then lock_Move=true        ** RR I always use a constant RR=0 for make this sentence... this it's a mine

Now when I do this:
if lock_Move
  inc x
  print "move",x,0
endif

the text a, always runs to the right becuase the variable "lock_Move" it's fixed to true, and the "Move" letter goes to the right forever

An important in this prashe
if                         a  =  true and RR=0 then lock_Move=true   
This  variable       'a' not have to be always put to true, if I only leave for a millisecod in true and the a turns again to false

the move text I put more above always runs to the rights, this becuase happends?¿, very easy becuase when I say

if a  =  true (pass 1 ms and now it's false) and RR=0 then lock_Move=true   

the lock_Move variable has change to true, then I lock whit this sentence using the If and Then in conjunction...

I don't kwow If I'm expressed well, but if you need help whit this comment me... Basically I never use THEN, except when I do this...

Regards, and don't care about asking anything the forum it's for this, today I rebember whit MSX (friend of forum), when I started and I'm glad about her words, something... You advanced a lot of from you begin.... I'm some years ago was exactly in the same or minus point like you... Take with calm, pick and pick and pick more Code, and THEN 1 year later we speak again...  :booze: ;)

Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-17
I am trying to get the computer to change the playfield when I click on a certain block of the grid. I am using the Help guide and following it exactly but when it doesnt work I come here and ask Ian Price or anyone else that reads this post and mentalthink as well.
But the problem is that the help guide contradicts what you guys say and the answers I get off the forum work. So is the Help guide even accurate? If you go to help/tutorials/the first game "  you will see the code I am trying to program. If you read the above messages, you will see that the right way often contradicts the help guide :help:
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: erico on 2013-Jan-17
It could be, blackout12.

Thing is, that GLBasic gets updated on a very fast fashion, bugs are fixed, things and new platforms are implemented, etc.
That way, it is sometimes hard to keep up with the help files.

People with prior knowledge on BASIC can, sometimes, go around that and figure out for themselves.
If you are really new to GLBasic, my best bet is that you fast read the manual a couple times to get the general idea, then, you work on the PONG tutorial/demo, that+manual should give you a standard understandment on how BASIC works and is structured.

It is really simple, almost like writing an email in english.

Attempt to modify things on the pong game sounds like a good next step.
After such, you will be more confident to produce your own stuff.

I´m not sure how the tutorials may be not up to date, but I usually have GLBasic running and the f1(help) running on my other monitor and I use it a lot, specially on command descriptions.

Just so that you know, I´m no god coder at all, I´m quite a noob with the exception that I had prior exposition to BASIC on older computers.
I have learned BASIC on my own from books(no internet on the 80s  :'() and it was medium hard but I really wanted to make it happen and so I did.

What we say here, is related to our own experiences. The way Ian might solve a code is different then mine and is different then Mr. Tatoad and so on.
Each of us have developed a style on coding, and so must you.

It is from these different styles that we all learn from each other.
Feel free to come around and ask things you need. But it is important that you develop a style of your own.

So, sometimes, it is better for us to give you a hint on where you may look for a solution instead of pasting our own complete solutions.
That way, you will develop your own style.

Keep it up! :good:
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: kanonet on 2013-Jan-17
And an other tip:

programming means breaking everything down to its smallest possible steps. The computer is really dumb, so you need to tell him what to do in many really small steps.

Like: the computer does not know a playfield, he just knows the array that you use to display a playfield. So when you want to alter the playfield you need to alter the array. But tell him to change something on the array wont do much, cause you need to tell him how to change it in detail - and you dont want to change the whole array, you just want to change one element, right? So tell him exactly what element you want to change in which way.
Like for example: Playfield[3][3]=1-Playfield[3][3]
This wont do exactly what you want, but you should be able to modify this in order to get it working like you want it.

Btw. like erico said everyone has its own style of coding and solving problems, so when you ask how to do things and you get an answer that is different from the tutorial, that does not necessarily mean that the tutorial is wrong, its just an other way how to solve the problem. This is one of the cool parts of programming, you can solve one problem in thousands of different ways and its totally up to you which way you choose. I had a quick look at the tutorial, for me everything looks fine and should work. (Note that i just looked at the code, not at the text.)
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Moru on 2013-Jan-17
I tried the first tutorial again today and all I need to do is add the declarations for the variables for everything to work.

Code (glbasic) Select
GLOBAL playfield[]
GLOBAL mx, my, b1, b2
GLOBAL level, mousefree, clicks
GLOBAL set


Don't know if everything needs to be global though but it works. What does not work is to try to run the game over teamviewer from another computer. The mouse gets accelerated at least 10 times and it's impossible to hit anything.
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-17
good advice, thank you for your help
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-17
Thank you guys so much for your help. I have figured out why my code isnt working...sort of. You see, no matter what I did to change my code for the game LOGO(I think) nothing mattered, when I clicked on the blue grid, nothing happened besides it registering how many times I clicked. As you would of guessed, this is very frustrating. So, I scrolled to the bottom of the help guide and copied and pasted the full code given. I expected that it would work, it did not, for some reason, even the master code given by the help did not allow me to change the grid when I clicked!!! Once before this happened to me when I was trying to do something else, I contacted GLBasic and found that I need to turn of explicit declarations. I did and it worked. This is different. does anyone have any idea why this is not working?!! :nw: :help: :help: :help:
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: fuzzy70 on 2013-Jan-17
Here is mine copied straight from the help file & it works on my system no problems. Only thing I done was to turn off "Explicit Declarations" in the "Project Options" menu.

The code :

Code (glbasic) Select
// --------------------------------- //
// Project: OneMore

DIM playfield[10][10]

   level = 0

   // Main game
   start:
      IF IsLevelComplete()
         GOSUB NewLevel
         mousefree=FALSE
      ENDIF

      MOUSESTATE mx, my, b1, b2
      IF b1
         IF mousefree THEN Click(mx/32, my/32)
         mousefree=FALSE
      ELSE
         mousefree=TRUE
      ENDIF
   
      GOSUB ShowPlayfield
      PRINT "<=", mx, my-8
      SHOWSCREEN
   GOTO start
END

// ------------------------------------------------------------- //
// -=#  SHOWPLAYFIELD  #=-
// ------------------------------------------------------------- //
SUB ShowPlayfield:
   LOCAL x, y, color[]

DIM color[2]
   color[0] = RGB( 50,  50, 255) // Not set
   color[1] = RGB( 50, 255,  50) // Set

   DRAWRECT 0,0, 320, 320, RGB(255,255,255)
   FOR x=0 TO 9
      FOR y=0 TO 9
         DRAWRECT x*32+1, y*32+1, 30, 30, color[playfield[x][y]]
      NEXT
   NEXT
   PRINT "Clicks: "+clicks, 360, 120
   PRINT "Level:  "+level, 360, 160
ENDSUB // SHOWPLAYFIELD


// ------------------------------------------------------------- //
// -=#  CLICK  #=-
// ------------------------------------------------------------- //
FUNCTION Click: x, y
   // These values are defined LOCAL:
   // x, y
   clicks=clicks+1
   Change(x-1, y)
   Change(x+1, y)
   Change(x, y)
   Change(x, y-1)
   Change(x, y+1)
ENDFUNCTION


// ------------------------------------------------------------- //
// -=#  CHANGE  #=-
// ------------------------------------------------------------- //
FUNCTION Change: x, y
   // These values are defined LOCAL:
   // x, y
   IF x>=0 AND x<10 AND y>=0 AND y<10
      set = playfield[x][y]
     
      IF set = TRUE
         set=FALSE
      ELSE
         set=TRUE
      ENDIF
      // or simply:
      // set = 1-set
      playfield[x][y]=set
   ENDIF
ENDFUNCTION


// ------------------------------------------------------------- //
// -=#  NEWLEVEL  #=-
// ------------------------------------------------------------- //
SUB NewLevel:
   LOCAL x, y, i

   // Clear playfield - just to be sure
   FOR x=0 TO 9
      FOR y=0 TO 9
         playfield[x][y]=FALSE
      NEXT
   NEXT

   level=level+1
   
   // Do random clicks
   FOR i=0 TO level
      Click(RND(9), RND(9))
   NEXT
   clicks=0
   GOSUB ShowPlayfield
   PRINT "Level: "+level + " - get ready", 0, 360
   SHOWSCREEN
   MOUSEWAIT
ENDSUB // NEWLEVEL


// ------------------------------------------------------------- //
// -=#  ISLEVELCOMPLETE  #=-
// ------------------------------------------------------------- //
FUNCTION IsLevelComplete:
   LOCAL x, y

   FOR x=0 TO 9
      FOR y=0 TO 9
         IF playfield[x][y]=TRUE THEN RETURN FALSE
      NEXT
   NEXT
   RETURN TRUE
ENDFUNCTION


I have also attached the compiled result & the project files for you to test on your system. Try the exe 1st then open the project & run it to see if both work ok. If not then there is something odd going on with your system. I deliberately left out adding the GLOBAL/LOCAL declarations to the code as to keep it an exact copy of the code posted in the help file.

Out of interest I presume you are compiling for Windows & not another target that GLBasic supoorts.

Also attached is my version of that game as like yourself it was one of the 1st things I played with after discovering GLBasic. I never got round to finishing it off completely as learnt what I needed & moved on to other things  :D

Lee

[attachment deleted by admin]
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-17
I fixed it
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-18
well, thank you guys so much for your advice and help, but it seems that all I had to do was delete the file I was using and redo everything for it to work. I will never know what was wrong with it originally but its fixed now. =D :D =D :D =D :D =D :D =D :D :D =D :D =D =D :D :D =D
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-18
Code (glbasic) Select
Main: 
DIM baty[2]
DIM batx[2]
DIM score[2]

//pre-settings
GOSUB Init
MainLoop:
  GOSUB MoveAll
  GOSUB ShowAll
GOTO Main


SUB Init:
GOSUB ResetBall
BLACKSCREEN
DRAWRECT 0,0, 640, 16,  RGB(255, 255, 255)
DRAWRECT 0, 464, 640, 480, RGB(255, 255, 255)
DRAWRECT 312, 0, 16, 480, RGB(255, 255, 255)
USEASBMP


baty[0]=240; baty[1]=240

batx[0]=16; batx[1]=600
ENDSUB

SUB ResetBall:

    ballx=320
    bally=240
   
    IF ballsx<0
     ballsx=1
    ELSE
     ballsx=-1
    ENDIF 
   
    ballsy=1
ENDSUB



SUB ShowAll:
FOR num=0 TO 1
  DRAWRECT batx[num], baty[num], 16, 64, RGB (255, 255, 255)
  PRINT score[num], num*320 + 32, 16
NEXT
DRAWRECT ballx, bally, 16, 16, RGB(255, 255, 255)
SHOWSCREEN
ENDSUB




SUB MoveAll:
  FOR num=0 TO 1
  IF KEY(30) THEN baty[0]=baty[0]-2
  IF KEY(44) THEN baty[0]=baty[0]+2
 
  IF KEY(200) THEN baty[1]=baty[1]-2
  IF KEY(208) THEN baty[1]=baty[1]+2
 
  IF baty[num]<0  THEN baty[num]=0
  IF baty[num]>416  THEN baty[num]=416
NEXT
ENDSUB
this code makes the bats move but only like a milimeter and then it cant go any further. any suggestions why it would do this?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: erico on 2013-Jan-18
Blackout12, I feel you are trying to create a program by adding blocks of code expecting it to work out of the box.
I see your code has some advanced things, like functions and types.

You can´t do a game by adding pieces of code from here and there, you must understand what is going on per line and command.
It seems to me you want to try a huge step instead of going on slowly.

Again, I´m no god coder, I can´t use types or functions yet, I´m learning.
But with the VERY little I know of GLBasic, I can reach what I want.
It may take a huge code and it may be un-optimized, but I can make what I want, and that is what matters.

So to make it clear, you can start coding on GLBasic with very little knowledge on commands (as I do).
But it is important that you know about these few commands AND language structure.

You seem to have the needed perseverance, and that is great!
You will get there, did you try the PONG tutorial?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: fuzzy70 on 2013-Jan-18
I'm not at my main pc at the moment but the error looks like the following, you have
Code (glbasic) Select

GOTO Main

in your code which means it sets up everything, does the game loop once then starts from the beginning. Try replacing the above with
Code (glbasic) Select
GOTO MainLoop
& try that. so the top part of your code looks like the following

Code (glbasic) Select

Main: 
DIM baty[2]
DIM batx[2]
DIM score[2]

//pre-settings
GOSUB Init
MainLoop:
  GOSUB MoveAll
  GOSUB ShowAll
GOTO MainLoop


That way it will initialize everything as normal & run the game loop rather that starting from the beginning every time.

Lee
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-18
I have Finished programming Pong but I have a midi file I want to play in the game, where in the code wuold I have to put it?
Code (glbasic) Select

main:
DIM bat_y[2]
DIM bat_x[2]
DIM score[2]
  GOSUB Init
  MainLoop:
    GOSUB MoveAll
    GOSUB ShowAll
  GOTO MainLoop



// ------------------------------------------------------------- //
// ---  INIT  ---
// ------------------------------------------------------------- //
SUB Init:

GOSUB ResetBall

BLACKSCREEN
DRAWRECT 0,0, 640, 16,  RGB(255, 255, 255)
DRAWRECT 0, 464, 640, 480, RGB(255, 255, 255)
DRAWRECT 312, 0, 16, 480, RGB(255, 255, 255)
USEASBMP


bat_y[0]=240; bat_y[1]=240

bat_x[0]=16;  bat_x[1]=600
ENDSUB // INIT




// ------------------------------------------------------------- //
// ---  RESETBALL  ---
// ------------------------------------------------------------- //
SUB ResetBall:


    ball_x=320
    ball_y=240

    IF ball_sx<0
     ball_sx=1
    ELSE
     ball_sx=-1
    ENDIF

    ball_sy=1
ENDSUB // RESETBALL




// ------------------------------------------------------------- //
// ---  SHOWALL  ---
// ------------------------------------------------------------- //
SUB ShowAll:
FOR num=0 TO 1
  DRAWRECT bat_x[num], bat_y[num], 16, 64, RGB(255, 255, 255)
  PRINT score[num], num*320 + 32, 16
NEXT
DRAWRECT ball_x, ball_y, 16, 16, RGB(255, 255, 255)
SHOWSCREEN
ENDSUB // SHOWALL




// ------------------------------------------------------------- //
// ---  MOVEALL  ---
// ------------------------------------------------------------- //
SUB MoveAll:
FOR num=0 TO 1

IF KEY(30) THEN bat_y[0]=bat_y[0]-2
IF KEY(44) THEN bat_y[0]=bat_y[0]+2

IF KEY(200) THEN bat_y[1]=bat_y[1]-2
IF KEY(208) THEN bat_y[1]=bat_y[1]+2

IF bat_y[num]<0  THEN bat_y[num] =0
IF bat_y[num]>416  THEN bat_y[num] =416
NEXT
    ball_x=ball_x+ball_sx
    ball_y=ball_y+ball_sy
   
IF ball_y>464
  ball_y=464
  ball_sy= -ball_sy
ENDIF

IF ball_y<0
  ball_y=0
  ball_sy= -ball_sy
  ENDIF

IF ball_x<0
  score[1]=score[1]+2
  GOSUB ResetBall
ENDIF
IF ball_x>624
  score[0]=score[0]+2
  GOSUB ResetBall
ENDIF

FOR num=0 TO 1
IF (ball_sx<0 AND num = 0) OR (ball_sx>0 AND num=1)
col=BOXCOLL(bat_x[num], bat_y[num], 16, 64, ball_x, ball_y, 16, 16)
IF col=TRUE
ball_sx = -ball_sx
ball_sx = ball_sx * 1.2
ball_sy = ball_sy *1.05
NEXT
ENDIF
ENDIF
ENDSUB
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-18
I have figured out where to put the music and it works. but how do I make a playlist?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: fuzzy70 on 2013-Jan-19
I could give you the code to do that but feel you would learn more from doing it yourself (that's the best way to learn as far as I concerned). So I will tell you the steps involved & you should have enough info to work it out.


You will also have to make sure to check that CurrSong does not go above the amount of songs in the list & if it does set it back to 0. Don't forget arrays start at zero & not 1, example
Code (glbasic) Select

DIM Song$[0]="Song1.mid"
DIM Song$[1]="Song2.mid"

IF CurrSong > 1 then CurrSong = 0


Lee
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Jan-19
please define step 1 and 2 further please
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Slydog on 2013-Jan-21
If it helps, here's my music library I created a couple of years back.
I don't know if I left it functional or not, it's been a while.
I do recall that when the Play List started the next song, it paused the entire game for a short second, before playing.
I think this is a GLBasic issue, as it pauses while it loads the song from disk, as there is no way to pre-load a song.
(At least that was a problem back then!)

Initialize:
It uses global constants for the sound effect IDs, and global ints for the music IDs.
Code (glbasic) Select
CONSTANT SOUND_MENU% = 2
CONSTANT SOUND_MOVE% = 3
CONSTANT SOUND_MOVE_UP% = 4
CONSTANT SOUND_MOVE_DN% = 5
CONSTANT SOUND_STAR% = 6

GLOBAL MUSIC_INTRO%
GLOBAL MUSIC_MENU%
GLOBAL MUSIC_GAMEOVER%
GLOBAL MUSIC_SONG1%
GLOBAL MUSIC_SONG2%
GLOBAL MUSIC_SONG3%
GLOBAL MUSIC_SONG4%

FUNCTION Sound_Initialize:
// MUSIC
MUSIC_INTRO = _Sound.Music_Add("intro")
MUSIC_MENU = _Sound.Music_Add("menu")
MUSIC_GAMEOVER = _Sound.Music_Add("gameover")
MUSIC_SONG1 = _Sound.Music_Add("song_01")
MUSIC_SONG2 = _Sound.Music_Add("song_02")
MUSIC_SONG3 = _Sound.Music_Add("song_03")
MUSIC_SONG4 = _Sound.Music_Add("song_04")
_Sound.Music_PlaylistSetFirst(MUSIC_SONG1)

// EFFECTS
_Sound.Effect_Add(SOUND_MENU, "ting", 1)
_Sound.Effect_Add(SOUND_MOVE, "move_01", 2)
_Sound.Effect_Add(SOUND_MOVE_UP, "move_02", 2)
_Sound.Effect_Add(SOUND_MOVE_DN, "move_03", 2)
_Sound.Effect_Add(SOUND_STAR, "flag_01", 1)
ENDFUNCTION


Usage:
Code (glbasic) Select
Somewhere in you main game loop, call:
_Sound.Music_PlayList()

// To play a specific song:
_Sound.Music_Play(MUSIC_INTRO, TRUE)

// To play a specific sound effect:
_Sound.Effect_Play(SOUND_MOVE_UP)


Sound Library:
Code (glbasic) Select
CONSTANT SOUND_PATH_MUSIC$ = "Sounds/Music/"
CONSTANT SOUND_PATH_EFFECTS$ = "Sounds/Effects/"

?IFDEF IPHONE
CONSTANT SOUND_MUSIC_EXT$ = ".m4a"
CONSTANT SOUND_EFFECTS_EXT$ = ".caf"
?ELSE
CONSTANT SOUND_MUSIC_EXT$ = ".mp3"
CONSTANT SOUND_EFFECTS_EXT$ = ".wav"
?ENDIF

GLOBAL _volume_music# = 0.5
GLOBAL _volume_effects# = 0.75

//==============================================================================
//  S O U N D
//==============================================================================

TYPE TSoundEffect
id%
channel%
volume#
pan#
is_playing%
ENDTYPE

TYPE TSound
music_ix%
music_playlist_first%
music$[]
effects[] AS TSoundEffect

FUNCTION Music_Add%: fn$
fn$ = SOUND_PATH_MUSIC$ + fn$ + SOUND_MUSIC_EXT$
DIMPUSH self.music$[], fn$
LOG(">Music Add: [" + fn$ + "] | ix:[" + BOUNDS(self.music$[], 0) - 1 + "]")
RETURN BOUNDS(self.music$[], 0) - 1
ENDFUNCTION

FUNCTION Music_PlaylistSetFirst%: first%
self.music_playlist_first = first
RETURN TRUE
ENDFUNCTION

FUNCTION Music_PlayList%:
IF self.music_ix < self.music_playlist_first
self.Music_Stop()
self.music_ix = self.music_playlist_first
ENDIF
IF self.Music_IsPlaying() = TRUE THEN RETURN
INC self.music_ix
IF self.music_ix >= BOUNDS(self.music$[], 0)
self.music_ix = self.music_playlist_first
ENDIF
LOG(">MUSIC :: Now Playing: [" + self.music$[self.music_ix] + "]")
PLAYMUSIC self.music$[self.music_ix], FALSE
self.Music_Volume(0.5)
RETURN TRUE
ENDFUNCTION

FUNCTION Music_Play%: song%, b_loop%=FALSE
IF song >= BOUNDS(self.music$[], 0) THEN RETURN
IF (self.music_ix = song) AND (self.Music_IsPlaying()) THEN RETURN

self.music_ix = song
self.Music_Stop()
PLAYMUSIC self.music$[self.music_ix], b_loop
self.Music_Volume(1.0)
RETURN TRUE
ENDFUNCTION

FUNCTION Music_IsPlaying%:
RETURN ISMUSICPLAYING()
ENDFUNCTION

FUNCTION Music_Volume: volume#
MUSICVOLUME volume * _volume_music
ENDFUNCTION

FUNCTION Music_Stop%:
STOPMUSIC
ENDFUNCTION

FUNCTION Effect_Add%: id%, fn$, buffers%=1, b_preload%=FALSE, volume#=1.0, pan#=0.0
LOCAL effect AS TSoundEffect
effect.id = id
effect.volume = volume
effect.pan = pan
effect.channel = BLANK
effect.is_playing = FALSE
fn$ = SOUND_PATH_EFFECTS$ + fn$ + SOUND_EFFECTS_EXT$
LOG(">Sound Add: [" + fn$ + "] | id:[" + id + "]")
LOADSOUND fn$, effect.id, buffers
DIMPUSH self.effects[], effect
IF b_preload = TRUE THEN self.Effect_Play(id, 0.0)
RETURN TRUE
ENDFUNCTION

FUNCTION Effect_Play%: id%, volume#=BLANK, pan#=BLANK
LOCAL ex%
ex = self.Effect_Find(id)
IF ex < 0 THEN RETURN FALSE
IF volume = BLANK THEN volume = self.effects[ex].volume
IF    pan = BLANK THEN    pan = self.effects[ex].pan
self.effects[ex].channel = PLAYSOUND(id, pan, 1.0)//_volume_effects * volume)
LOG("Effect_Play: [" + id + "]")
RETURN TRUE
ENDFUNCTION

FUNCTION Effect_IsPlaying%: id%
LOCAL ex%
ex = self.Effect_Find(id)
IF ex < 0 THEN RETURN FALSE
RETURN SOUNDPLAYING(self.effects[ex].channel)
ENDFUNCTION

FUNCTION Effect_Find%: id%
LOCAL ex%
FOR ex = 0 TO BOUNDS(self.effects[], 0) - 1
IF self.effects[ex].id = id THEN RETURN ex
NEXT
RETURN BLANK
ENDFUNCTION

FUNCTION Sound_Mute%:
self.Music_Volume(0.0)
HUSH
RETURN TRUE
ENDFUNCTION

FUNCTION Sound_GetNextId%: b_reset% = FALSE
STATIC id% = 1000
IF b_reset = TRUE THEN id = 0
INC id
RETURN id
ENDFUNCTION
ENDTYPE

FUNCTION LOG: message$, add_linefeed% = TRUE, show_time% = TRUE
STATIC datetime% = -1 // Log timer
LOCAL elapsed# // How much time has elapsed since program start (or manual reset)
IF datetime < 0 THEN datetime = GETTIMERALL() // Initialize log timer if not already set
IF message$ = "RESET" THEN datetime = GETTIMERALL() // Manually reset log timer
elapsed = (GETTIMERALL() - datetime) / 1000.0
?IFDEF WIN32
IF show_time = TRUE THEN DEBUG "[" + FORMAT$(8, 3, elapsed) + "] "
DEBUG message$
IF add_linefeed THEN DEBUG "\n"
?ELSE
INLINE
STDOUT(message_Str);
ENDINLINE
?ENDIF
ENDFUNCTION
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Moru on 2013-Jan-21
Quote from: blackout12 on 2013-Jan-19
please define step 1 and 2 further please
If you have a look at the post above yours, he already specified step 1 and 2 by doing them for you :-)
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: blackout12 on 2013-Feb-12
Code (glbasic) Select
SETCURRENTDIR ("Media")



LOADSPRITE "person1.bmp" ,0

LOADSPRITE "bullet.bmp" ,1

LOADSPRITE "Desert.bmp" ,2





WHILE TRUE

MOUSESTATE mx, my, b1, b2

DRAWRECT 0,0,640, 480,RGB(255,255,255)

DRAWSPRITE 0, 100,100

DRAWSPRITE 1, mx, my

    IF b1 = TRUE THEN
   
DRAWSPRITE  2, 0,0

SHOWSCREEN

WEND
  this is my code, all it does is if you click, it loads a new image, how would I make it so that it only loads the image when i click on "person1"?
Title: Re: Help for NEWBIES. NOTE: I am a newbie so I cant really help.
Post by: Sokurah on 2013-Feb-12
Quote from: blackout12 on 2013-Feb-12this is my code, all it does is if you click, it loads a new image, how would I make it so that it only loads the image when i click on "person1"?
No, you currently already load all the images. What you want to say is "what do you need to do to show another image".

Here's a bit of pseudo code to get you going.

QuoteLoad image1
Load image2
Repeat
   thisvariable=1
   if imagecollide (mouse, image) then thisvariable=2
   if thisvariable=1 then showimage image1
   if thisvariable=2 then showimage image2
Until something

..it's really all there is to it. ;)