help with player selection...

Monkey Forums/Monkey Beginners/help with player selection...

dubbsta(Posted 2017) [#1]
so in my SelectionScreen i can pick types of ships and its color using "frame", but i want to take the selected ship in the game mode but i cant use frame for some reason. i extended SelectionScreen and if i use "ship" "selector" selected" it works fine but wont change frome frame 1.

Class SelectionScreen
  Field selector:Int= 1
  Field frame:Int
  Field fighter:Int = 0 
  Field bomber:int = 4
  Field stealth:int = 8
  Field ufo:Int = 12
  
  Field ship:Image
  Field ship_names:Image
  Field p_select:Image
  Field infoframe:Image
  Field glass:Image
  Field ship_smbl:Image
  Field info:Image
  Field start:Image
  Field metalP:Image
  
  Field startNow:Int = 0
  Field x:Int 
  Field y:Int 
  Field menu:Sound
  Field selected:Int
   
  
		Method New()
		    Self.frame = frame
			start = LoadImage("PNG/UI/start1.png",1,Image.MidHandle)
			info = LoadImage("PNG/UI/info.png",258/3,18,3)
			ship_smbl = LoadImage("PNG/UI/ship_smbl.png",840/4,137,4,Image.MidHandle)
			menu = LoadSound("sounds/menu.wav")
			metalP = LoadImage("PNG/UI/UI_pack_Space/PNG/metalPanel.png",1,Image.MidHandle)
			glass = LoadImage("PNG/UI/UI_pack_Space/PNG/glassPanel_corners.png",1,Image.MidHandle)
			infoframe = LoadImage("PNG/UI/UI_pack_Space/PNG/metalPanel_greenCorner.png",1,Image.MidHandle)
			p_select = LoadImage("PNG/UI/p_select.png",1,Image.MidHandle)
			ship_names = LoadImage("PNG/UI/ship_names1.png",560/4,21,4,Image.MidHandle)
			ship = LoadImage("PNG/playerShip.png",112,91,18 ,Image.MidHandle)
			
		End 
		
		Method Update:Int()	
				
			Return 0 
		End 
		 
		Method Draw:Int()
			Cls(128,128,128)
			
			DrawImage(metalP,startX-100,startY-55,0,1,.5)
			DrawImage(start,screenWidth-100,screenHeight-55)
			DrawImage(ship,x+screenWidth/2-150,y+screenHeight/2,0,.5,.5,frame)'*****HERE
			DrawImage(glass,screenWidth/2-150,screenHeight/2)
			DrawImage(infoframe,screenWidth/2+150,screenHeight/2,0,2,2)
			DrawImage(info,375,215,0)
			DrawImage(info,375,255,1)
			DrawImage(info,385,295,2)
			DrawImage(ship_smbl,screenWidth/2-150,screenHeight/2+100,0,.7,.7,selector -1)
			SetColor(255,255,255)
			DrawImage(p_select,screenWidth/2-150,screenHeight/2-100)
			
			Return 0 
		End 
	 	
	 	Method Selector:Int()
	 		If KeyHit(KEY_UP) Then selector -= 1 ; PlaySound(menu)
	 		If KeyHit(KEY_DOWN) Then selector += 1 ; PlaySound(menu)
	 		
	 		If selector > 4 Then selector = 1 
			If selector < 1 Then selector = 4
			
			If KeyHit(KEY_RIGHT) Or KeyHit(KEY_LEFT) Then PlaySound(menu)
			
			
	 		If selector = 1 
	 		  selected = frame		 
				frame = fighter
				If KeyHit(KEY_RIGHT) 
				fighter += 1
				If fighter > 3 Then fighter = 0
				End 	 
				If KeyHit(KEY_LEFT)  
				fighter -= 1
				If fighter < 0 Then fighter = 3
				End 
			Else 
			fighter = 0
			End 
			
	 		If selector = 2 
	 		  selected = frame
				frame = bomber
				If KeyHit(KEY_RIGHT) 
				bomber += 1
	 			If bomber > 7 Then bomber = 4
	 			End 
	 			If KeyHit(KEY_LEFT)
	 			bomber -= 1
	 			If bomber < 4 Then bomber = 7
	 			End 
	 	 	Else
	 	 	bomber = 4
	 	 	End  
	 	 	
	 		If selector = 3
	 		  selected = frame
				frame = stealth 
				If KeyHit(KEY_RIGHT)      
				stealth += 1
				If stealth > 11 Then stealth = 8 
				End 
				If KeyHit(KEY_LEFT)
				stealth -= 1
				If stealth < 8  Then stealth = 11
				End 
			Else
			stealth = 8
			End 
			
	 		If selector = 4
	 		  selected = frame
				frame = ufo
				If KeyHit(KEY_RIGHT)
				ufo += 1
	 			If ufo > 15 Then ufo = 12
	 			End 
	 			If KeyHit(KEY_LEFT)
	 			ufo -= 1
	 			If ufo < 12 Then ufo = 15
	 			End 
	 		Else 
	 		ufo = 12
	 		End   	
	 		Return selected 
	 	End  
	 	
	 	Method GetSelector:Int()
	 	
	 		Return frame 
	 	End 
	 	
	 	
 Field startX:Int = 640
 Field startY:Int = 480
	 	Method startGame:Int()
	 		If Not MouseX() <= startX-100 - 50 Or  Not MouseX() >= startX-100 + 50 Or Not MouseY() <= startY-55 - 25 Or Not MouseY() >= startY-55 + 25 
				If 
				MouseHit(MOUSE_LEFT) 
	 	    	startNow = 1
	 	    	
	 	    	End  
	 	    End  
	 		Return 0
	 	End 
	 	 
End    



Class SetUp Extends SelectionScreen
 
  Field pX:Int = screenWidth/2
  Field pY:Int = screenHeight - 25
  Field Xposition:Int 
  Field Yposition:Int 
  Field speed:Int
  
  			Method New(pX:Int,pY:Int,vel:Int) 
  				 
  				Self.pX = pX 
  				Self.pY = pY 
  				pX = screenWidth/2
  				pY = screenHeight - 25
  				
  				speed = 5
  			
  			 
  			End
  			
  			Method control:Int()
  			
  				If KeyDown(KEY_RIGHT)
  					pX += 4
  				End 
  				If KeyDown(KEY_LEFT)
  					pX -= 4
  				End 
  				Return 0 
  			End 
  			
  			Method Draw:Int()
  				DrawImage(ship,pX,pY,0,.3,.3,selected) '********HERE
  			
  				Return 0  
  			End 
  			
  			
End 




Gerry Quinn(Posted 2017) [#2]
I haven't run this, but it looks like in method Selector, you set selected to frame BEFORE changing frame. So frame gets changed okay, but selected is always the original value.


dubbsta(Posted 2017) [#3]
i tried using frame before but nothing, will keep trying in the meantime if anyone wants to dig deeper ill upload source

https://www.dropbox.com/sh/wxgm7tkzzjshnpw/AAD8qnXqAFD4KQCJnw661K8na?dl=0