Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - blackout12

#1
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"?
#2
please define step 1 and 2 further please
#3
I have figured out where to put the music and it works. but how do I make a playlist?
#4
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
#5
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?
#6
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
#8
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:
#9
good advice, thank you for your help
#10
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:
#11
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.
#12
do you think you know what the problem is?
#13
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
#15
how would you go about making a click routine?