|
Post by Wayne Rayner on Dec 28, 2009 4:17:17 GMT -5
Ok so basically I have read the programmers guide about using the mouse button and that just shows if mouse is clicked then true. So then I looked at the moving mouse example and I added it to my program and it went heywire. The images were constantly refreshed.
What I think I need is to know how to get the coordinates of where the buttons are and add them into the code to have a working button.
Here is the source code: without mouse input. All I want is the coordinates and I will try and figure out how to make the buttons work.
' Game World: It's all about the game ' Ray Corp Games
' declare variables ' menu variables dim men_bak, men_bak_tex dim new_game_btn, new_game_btn_tex dim load_game_btn, load_game_btn_tex dim options_btn, options_btn_tex dim exit_btn, exit_btn_tex ' main ' Menu ' load background image men_bak_tex = LoadTex ("images\background.png")
men_bak = NewSprite (men_bak_tex) SprSetPos (320,240) SprSetSize (640,480) BindSprite (men_bak)
' load buttons ' new game button new_game_btn_tex = LoadTex ("images\new_game_btn.png")
new_game_btn = NewSprite (new_game_btn_tex) SprSetPos (320,150) SprSetSize (150,50) SprSetZOrder (-1) BindSprite (new_game_btn)
' load game button load_game_btn_tex = LoadTex ("images\load_game_btn.png")
load_game_btn = NewSprite (load_game_btn_tex) SprSetPos (320, 200) sprSetSize (150,50) SprSetZOrder (-1) BindSprite (load_game_btn)
' options button options_btn_tex = LoadTex ("images\options_btn.png")
options_btn = NewSprite (options_btn_tex) SprSetPos (320, 250) SprSetSize (150,50) SprSetZOrder (-1) BindSprite (options_btn)
' exit button exit_btn_tex = LoadTex ("images\exit_btn.png")
exit_btn = NewSprite (exit_btn_tex) SprSetPos (320,300) SprSetSize (150,50) SprSetZOrder (-1) BindSprite (exit_btn)
' Enable mouse click on buton
if you need the images I will upload them on request Hope I'm explaining my problem properly Wayne Rayner
|
|
|
Post by crazynate on Dec 28, 2009 10:58:48 GMT -5
So your'e going with Ray Corp Games instead of Fire Flame Studios?
I would like to help you but it's hard to see what going on without any graphics. So yes, i do need you to upload the images.
|
|
|
Post by shadow008 on Dec 28, 2009 20:08:49 GMT -5
im pretty sure i know what your problem is somewhere(anywhere) before the main loop put: TextMode(text_buffered) and before the end of your loop (loop,wend,ect...) put: AnimateSprites() DrawText() i hope this solves your problems! EDIT: guess i didnt read your whole post... place mouse by: bindsprite(mouse_sprite) sprsetpos(mouse_x()*640,mouse_y()*480) mouse_x_variable = sprx() mouse_y_variable = spry() that should do it
|
|
|
Post by Wayne Rayner on Dec 28, 2009 21:12:59 GMT -5
Ok yea Shadow that works lol, now I need to get a Mouse Sprite. I will upload images soon and I will hopefully finnish creating the New Game button and make it go to another screen.
Yours Wayne Rayner
|
|
|
Post by Wayne Rayner on Dec 29, 2009 1:15:15 GMT -5
Ok I have uploaded the images folder. Can some one atleast give me an example of how to get a button to work please. Your help will be valued Yours Wayne Rayner Attachments:
|
|
|
Post by crazynate on Dec 29, 2009 4:16:49 GMT -5
I hope this helps ' Game World: It's all about the game ' Ray Corp Games & CrazyNate Studios
TextMode(text_buffered)
dim cursor(1),i dim menubackground dim button(3),texture(4),buttonactive
'''''''''''''''' ' load textures' '''''''''''''''' ' background image texture(0) = LoadTex ("images\background.png") ' new game button texture(1) = LoadTex ("images\new_game_btn.png") ' load game button texture(2) = LoadTex ("images\load_game_btn.png") ' options button texture(3) = LoadTex ("images\options_btn.png") ' exit button texture(4) = LoadTex ("images\exit_btn.png")
'''''''''''''''''''' 'creates background' '''''''''''''''''''' menubackground = NewSprite (texture(0)) SprSetPos (320,240) SprSetSize (640,480) SprSetZOrder (999)
''''''''''''''''''''''''''''''''''''''' 'creates and places all of the buttons' ''''''''''''''''''''''''''''''''''''''' for i=0 to 3 button(i) = NewSprite (texture(i+1)) SprSetPos (windowwidth()/2,(i*50)+150) SprSetSize (150,50) SprSetZOrder (90) next
''''''''''' 'main loop' ''''''''''' while true
''''''''''''''''''''''''''''''''' 'gets the position of the cursor' ''''''''''''''''''''''''''''''''' cursor(0) = mouse_x()*640 cursor(1) = mouse_y()*480
'''''''''''''''''''''''''''''''''''''''''''' 'tests to see if cursor is over any buttons' '''''''''''''''''''''''''''''''''''''''''''' 'sprleft =left side of a sprite 'sprright =right side of a sprite 'sprtop =top of a sprite 'sprbottom =bottom of a sprite if cursor(0)>(sprleft(button(0))) and cursor(0)<(sprright(button(0))) and cursor(1)>(sprtop(button(0))) and cursor(1)<(sprbottom(button(0))) then color(255,255,255) locate 0,0: print "New " buttonactive=1 elseif cursor(0)>(sprleft(button(1))) and cursor(0)<(sprright(button(1))) and cursor(1)>(sprtop(button(1))) and cursor(1)<(sprbottom(button(1))) then color(255,255,255) locate 0,0: print "Load " buttonactive=2 elseif cursor(0)>(sprleft(button(2))) and cursor(0)<(sprright(button(2))) and cursor(1)>(sprtop(button(2))) and cursor(1)<(sprbottom(button(2))) then color(255,255,255) locate 0,0: print "Options" buttonactive=3 elseif cursor(0)>(sprleft(button(3))) and cursor(0)<(sprright(button(3))) and cursor(1)>(sprtop(button(3))) and cursor(1)<(sprbottom(button(3))) then color(255,255,255) locate 0,0: print "Exit " buttonactive=4 else clearregion(0,0,10,0) buttonactive=0 endif
'''''''''''''''''''''''''''''''''''''''''''''''''' 'tests to see if the left mouse button is clicked' '''''''''''''''''''''''''''''''''''''''''''''''''' 'button(0)=left 'button(1)=right 'button(2)=middle if mouse_button(0)=true and buttonactive=1 then color(255,0,0) locate 0,0: print "New " elseif mouse_button(0)=true and buttonactive=2 then color(255,0,0) locate 0,0: print "Load " elseif mouse_button(0)=true and buttonactive=3 then color(255,0,0) locate 0,0: print "Options" elseif mouse_button(0)=true and buttonactive=4 then color(255,0,0) locate 0,0: print "Exit " endif
'CRAZYNATE WAZ HERE
drawtext() wend And look! Comments!!!
|
|
|
Post by Wayne Rayner on Dec 29, 2009 4:35:45 GMT -5
Ok firstly
It helps alot
Secondly
I love the comments especially the ones about crazynate studios and that crazy nate ws here.
I have to say I will put on the main menu a logo for crazynate studios if you like.
So yea thanks for the help yours Wayne rayner
|
|
|
Post by crazynate on Dec 29, 2009 4:42:05 GMT -5
maybe you could just put the logo in the credits
|
|
|
Post by Wayne Rayner on Dec 29, 2009 4:47:31 GMT -5
ok if thats what you want.
Also I is sprleft, sprright,sprtop,sprbottom functions from basicGl
|
|
|
Post by crazynate on Dec 29, 2009 5:16:23 GMT -5
So what type of game is it going to be? Or are you just going to use this as a template for future programs?
|
|
|
Post by Wayne Rayner on Dec 29, 2009 7:22:52 GMT -5
So what type of game is it going to be? Or are you just going to use this as a template for future programs? Ok well the game is going to be a game about game making. So now you will want an explanation. Yes Well you start off with $500 cash enough to buy rights to a indie game engine. You then start the project and after a while you have completed it. You get a small time publisher to publish it and you pay them whatever the publisher wants for publishing it. You get some money for that game and so forth. when you have some cash you can hire people to help you and maybe buy a better engine. After a while you can make your own game engine's and then when you have enough money you can become a publisher. When your publishing company becomes bigger you get bigger games come your way. While you are doing this you are competing against the big companies in the world and you also compete against a couple of small time companies. Thats basically the basics of the game. The game is called Game World and the catch phrase is it's all about the game Yours Wayne Rayner
|
|