Post by Wayne Rayner on Dec 29, 2009 5:19:11 GMT -5
' 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
''''''''''''''''''''''''''''''''''''''''''''''''''''
' creates New Game Page '
''''''''''''''''''''''''''''''''''''''''''''''''''''
if mouse_button(0)=true and buttonactive=1 then
DeleteSprite (menubackground)
DeleteSprite (button (0))
DeleteSprite (button (1))
DeleteSprite (button (2))
DeleteSprite (button (3))
color (255,255,255)
printr "new Game"
endif
drawtext()
wend
Ok I have another problem (again)
this problem is about the new game screen i have created. as you can see in the code I want it to print new game.
What happens is it gets deleted or it goes heywire. I believe it's some thing to do with the mouse button test crazynate wrote. But I don't know if thats the problem.
Yours
Wayne rayner