Posted: 26th Feb 2022 14:10
You should let createText() generate the ID of each and assign its returned integer value to a variable. Much easier to manage and no worries of using duplicate IDs.
Posted: 26th Feb 2022 14:18
short follow-up:

so far, NumPlayers has been a Local variable. since you'll probably use that value throughout the game, there are benefits to declaring it as a Global variable that functions can use, etc.

do you see how this might work?

+ Code Snippet
SetWindowSize( 1280,720, 0 )
SetWindowAllowResize( 1 )

// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) 
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )

GLOBAL Players as String []
GLOBAL MaxPlayers = 8
GLOBAL NumPlayers as Integer

Repeat
	Print("Number of Players? (1-"+STR(MaxPlayers)+")")
	NumPlayers = VAL( CHR (GetRawLastKey()) )
	Sync()
Until NumPlayers > 0 and NumPlayers <= MaxPlayers

AddPlayers()

do

    If GetRawKeyState(27) then End    

    For x = 0 to Players.Length
		Print("Player "+STR(x+1) + ": " + Players[x])
	Next x
    Sync()
loop

Function AddPlayers()
	TempTextID = CreateText("")
		SetTextSize(TempTextID,36)
		SetTextPosition(TempTextID, 100,50)
	For x = 1 to NumPlayers
		SetTextString(TempTextID, "Enter Player " + STR(x) + " Name:")
		ThisPlayerName$ = Input_Player_Name()
		Players.Insert(ThisPlayerName$)
	Next x
	DeleteText(TempTextID)
EndFunction

Function Input_Player_Name()
    StartTextInput ( )
    Repeat
		Name$ = GetTextInput ()
        Sync()
    Until GetTextInputCompleted() = 1
EndFunction Name$


Note the addition of:

+ Code Snippet
GLOBAL NumPlayers as Integer

...before we define it.

and now the AddPlayers() function doesn't need a parameter. it will simply reference whatever NumPlayers is set to Globally:

+ Code Snippet
Function AddPlayers()
	TempTextID = CreateText("")
		SetTextSize(TempTextID,36)
		SetTextPosition(TempTextID, 100,50)
	For x = 1 to NumPlayers
		SetTextString(TempTextID, "Enter Player " + STR(x) + " Name:")
		ThisPlayerName$ = Input_Player_Name()
		Players.Insert(ThisPlayerName$)
	Next x
	DeleteText(TempTextID)
EndFunction
Posted: 26th Feb 2022 23:46
You should let createText() generate the ID of each and assign its returned integer value to a variable. Much easier to manage and no worries of using duplicate IDs.


Yea, I'm going to re write a lot of the code

o you see how this might work?


Yes, I see how it might work. I usually declare all my variables global or at least most of them
Posted: 27th Feb 2022 1:12
I had no clue we could change the text of a text object on the fly. That's sweet!
Posted: 27th Feb 2022 23:03
Is there a way to load an image behind an text entry box started by StartTextInput()? I know you can change the background color using SetClearColor() before StartTextInput(), but I'd like to put an image if possible
Posted: 27th Feb 2022 23:26
if you want anything more than stock text input, i would get away from Text Input and opt for using Edit Boxes.

there, you have much more control and functionality including the ability to set its background image.
Posted: 27th Feb 2022 23:32
here, you have much more control and functionality including the ability to set its background image.



I thought I would have to do that, I had an EditBox in with an image behind it before I started this thread, but opted to change and now I want to change back, I need to figure out how to do the input connected to the EditBox now.

Thank you all for your help, I'm getting right on the EditBox stuff now lol
Posted: 28th Feb 2022 2:35
This is how I do it in everything I write.

First I create my edit box

+ Code Snippet
CreateEditBox( 1 )
SetEditBoxBorderSize( 1, 0.5 )
SetEditBoxBorderColor( 1, 0, 0, 0, 255 )
SetEditBoxMaxChars( 1,8 )
SetEditBoxPosition( 1, 30, 25 )
SetEditBoxSize( 1, 15.5, 4)
SetEditBoxTextSize( 1, 10 )
SetEditBoxCursorWidth( 1, 0.3 )
SetEditBoxCursorPosition( 1,5)
SetEditBoxScissor( 1, 0, 0, 0, 0 )
FixEditBoxToScreen ( 1, 1 )
SetEditBoxPosition( 1, 17.5, 34.5 )


Then I add a variable to assign to my edit box value

+ Code Snippet
     Name$= GetEditBoxText( 1 )
  
     SetEditBoxText( 1, Name$  ) 


Now with a edit box it is just a object sprite so you can add anything behind it or in front .

I didn't know if you knew so I thought I show you.
Posted: 28th Feb 2022 2:53
didn't know if you knew so I thought I show you.


Yes, I have created a EditBox before, but it was just a basic one with a couple of commands not making it fancy or anything. I have not been able to get it working with detecting the input text yet. By the looks of your 2nd snippet, I must have not seen the GetEditBoxText() and SetEditBoxText() commands yet. I must have overlooked them lol

I've sat here for an hour trying different things to no avail lol.

Thank you Game_Code_here for showing me how you do it. I have learned a good amount of AppGameKit over the last 6 months or so, but I have a lot more to learn
Posted: 28th Feb 2022 3:47
Hmm, I'm not sure why I can't get the input text to work. I see the text typed out on screen, but when I press enter nothing happens. If I come up with something that exits the function(whether it works or not I don't know) I get an error saying an image can't be loaded because the ID is already in use in an #include file that hasn't been accessed yet
Posted: 28th Feb 2022 5:24
I see the text typed out on screen, but when I press enter nothing happens


You just need to save the input as a variable.

The program as it runs keeps any text input into memory.

I get an error saying an image can't be loaded because the ID is already in use in an #include file that hasn't been accessed yet


I can not answer you there because I do not know all your code for every file but,

If you are using your include file after the creation of the text this could be the problem maybe.
Posted: 28th Feb 2022 9:17
I wrote this small example for you.

+ Code Snippet
// Project: name 
// Created: 2022-02-27

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "name" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

CreateEditBox( 1 )
SetEditBoxBorderSize( 1, 5.0 )
SetEditBoxBorderColor( 1, 0, 0, 0, 255 )
SetEditBoxMaxChars( 1,8 )
SetEditBoxSize( 1, 300, 50)
SetEditBoxTextSize( 1, 80 )
SetEditBoxCursorWidth( 1, 5 )
SetEditBoxCursorPosition( 1,1)
SetEditBoxScissor( 1, 0, 0, 0, 0 )
FixEditBoxToScreen ( 1, 1 )
SetEditBoxPosition( 1, 350 ,350 )
SetEditBoxFocus(1,1)	

    Name_text=CreateText ( "" )
	SetTextPosition ( Name_text,5.5, 30)
	SetTextSize ( Name_text, 5 )
	FixTextToScreen ( Name_text, 1 )
    SetTextColor(Name_text,0,0,0,255)
    SetTextVisible(Name_text,0)
    
Name$= GetEditBoxText( 1 )
SetEditBoxText( 1, Name$  )

    
do
	

Wrote_Name=GetEditBoxCursorPosition( 1 )
Name$= GetEditBoxText( 1 )
print( Name$)

    Sync()
loop
Posted: 28th Feb 2022 19:16
I wrote this small example for you

I'm not sure if I told exactly what I was trying to do with this menu code I'm working on.

What I was refering to in my last post was that the text input by the user is being seen as I type it, but when I hit the enter key the cursor disappears and the program sits there and does nothing. It isn't moving on to the next thing.

The purpose of the input by the user is to input the name they want to use as the acount name that their game will be (at a later time of their choosing) saved under and used to play the game when they boot the game back up. I'm trying to set up the "manager name input screen" and up to 8 players can play. So if more than one person is playing, that is the purpose of changing the number in the text object to the next number as each player inputs their name.

Thank you Game_Code_here for the example. I will take a look at it today. I have been unsure what to put in the do/loop to get it to work. I tried for about 2 hours last night to no avail. I was trying to use the code you gave me with the array entry stuff in it and changing things to work with my variable names and editing out the code I don't need such as pressing keys 1-8 to choose the number of players because the previous menu before the one I'm currently working on is the one to choose how many players. It has 8 buttons to click on numbered 1-8 and that sets "Account_Num_Players" variable to the number of players that need to input their names on this screen. I ran your example in a test project and changed the variables needed to work with my code and it cycled through and printed all input names out perfectly at the end, but as you know I need to do this manually with creating a EditBox so I can put an image behind it and now getting it set up to save in an array to be able to save whenever desired isn't working yet. If I choose more than one player that is playing, it only lets me input one name and doesn't change text object above editbox to say the next player can input their name. As soon as I input the first name and hit enter the text stays there and cursor disappears and just sits there. I know I will eventually figure this out LOL. I want to have help, but don't want people to do my code for me for I'm not that way. I am learning it just takes time. Things were easy in DarkBasic Pro for something like this, but this is the same, but different in my opinion LOL
Posted: 1st Mar 2022 3:07
Ok I see, sorry.

In this case I need to ask are you working on a server for players or home controller players?

But to be honest if I had to choose how many players with names I would set up many inputs more then one.

Then if there is a name in each input that is how many players, you can determine how many players due to how many names.

Not the only way but to me simple.

GetCurrentEditBox
Description
Returns the ID of the currently active edit box, only one edit box may focus at a time. If no edit box currently has focus it returns 0.

So if you click on a edit box that edit box has focus, then the player adds the name then the next edit box is clicked on, you will have to save each name differently due to each edit box.


+ Code Snippet
Player_1$= GetEditBoxText( 1 )
Player_2$= GetEditBoxText( 2 )
Player_3$= GetEditBoxText( 3 )
Player_4$= GetEditBoxText( 4 )
Player_5$= GetEditBoxText( 5 )
Player_6$= GetEditBoxText( 6 )
Player_7$= GetEditBoxText( 7 )
Player_8$= GetEditBoxText( 8 )


SetEditBoxText( 1, Player_1$  ) 
SetEditBoxText( 2, Player_2$  ) 
SetEditBoxText( 3, Player_3$  ) 

So on and so forth
Posted: 1st Mar 2022 4:28
I updated the small example, not much but a great idea. Now you just check to see how many names are added to determine how many players before the game jump happens.


+ Code Snippet
// Project: name 
// Created: 2022-02-27

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "name" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts


P=50
for x=1 to 8

CreateEditBox( x )
SetEditBoxBorderSize( x, 5.0 )
SetEditBoxBorderColor( x, 0, 0, 0, 255 )
SetEditBoxMaxChars( x,8 )
SetEditBoxSize( x, 300, 50)
SetEditBoxTextSize( x, 80 )
SetEditBoxCursorWidth( x, 5 )
SetEditBoxCursorPosition( x,1)
SetEditBoxScissor( x, 0, 0, 0, 0 )
FixEditBoxToScreen ( x, 1 )
SetEditBoxPosition( x, 350 ,P )
inc P,90
next x

SetEditBoxFocus(1,1)	

SetEditBoxText( 1, Name_1$  )
SetEditBoxText( 2, Name_2$  )
SetEditBoxText( 3, Name_3$  )  
SetEditBoxText( 4, Name_4$  )
SetEditBoxText( 5, Name_5$  )
SetEditBoxText( 6, Name_6$  )
SetEditBoxText( 7, Name_7$  )
SetEditBoxText( 8, Name_8$  )

P=5
For x=1 to 8
createtext(x,"Player="+str(x))	
SetTextSize(x,50)
SetTextPosition(x,410,P)
inc P,90
next x
 
do
	

Name_1$ = GetEditBoxText( 1 )
Name_2$ = GetEditBoxText( 2 )
Name_3$ = GetEditBoxText( 3 )
Name_4$ = GetEditBoxText( 4 )
Name_5$ = GetEditBoxText( 5 )
Name_6$ = GetEditBoxText( 6 )
Name_7$ = GetEditBoxText( 7 )
Name_8$ = GetEditBoxText( 8 )


print( "Player 1=" + Name_1$)
print( "Player 2=" +  Name_2$)
print( "Player 3=" +  Name_3$)
print( "Player 4=" +  Name_4$)
print( "Player 5=" +  Name_5$)
print( "Player 6=" +  Name_6$)
print( "Player 7=" +  Name_7$)
print( "Player 8=" +  Name_8$)

    Sync()
loop
Posted: 1st Mar 2022 10:29
Thank you for the updated example. I'll try to look at it today. I didn't get a chance to look at the original one yesterday yet.
Posted: 10th Mar 2022 0:39
o if you click on a edit box that edit box has focus, then the player adds the name then the next edit box is clicked on, you will have to save each name differently due to each edit box.


Sorry for not responding for awhile, I took some time away from this project to work on something else. I do that to clear my mind and take a break from something that is giving me trouble, then I come back to it.

In this case I need to ask are you working on a server for players or home controller players?


To answer this question, I want both local at home players and a (server eventually). First I want to get at home players going and then I will add a server later. I'd like to get the base game working first.
Posted: 10th Mar 2022 19:48
Start here

GetRawJoystickExists
Description
Returns 1 if a joystick exists at the given index. Physical joysticks are detected at startup and placed in IDs 1-8 incrementally. You should call CompleteRawJoystickDetection at some point before this command to make sure that all present joysticks have been discovered. After the initial detection process plugging in additional joysticks will not be detected (except on Android which will detect new joysticks). Unplugging a joystick will not delete its index and this command will still return 1. You can use GetRawJoystickConnected to detect when a previously detected joystick is disconnected. If a disconnected joystick is reattached the AppGameKit will attempt to reconnect to it.

An alternative version of this command exists GetJoystickExists, in which case it will return 1 if there are any raw joysticks attached
Posted: 11th Mar 2022 14:19
I can't use that command because the game will not be playable with joysticks. Only mouse, keyboard or by touch. You won't be controlling any players on field in regards to moving them around and passing and kicking the ball. This will be strictly a coaching or manager game. At best you will be able to click a player on field and tell him to play forward, backwards, left or right more to accommodate for what the opposing team is doing. Them players will move strictly by AI according to their player attributes
Posted: 11th Mar 2022 18:41
I see

Well that is easy enough,

Just structure the app to play due to each player.

If Player_1=1

do stuff

endif

Or even like this

for x=1 to 8

if Player[x].Exisit=1

do stuff

endif

next x

I would set up a type then a array for all players

Type Player
Num
Xpos
Ypos
endtype

That way You can control all aspects for each players conditions.

But I'm sure you probably figured all this out, Keep us posted, I would like to see how this turns out.