Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Getting mad with text commands

Author
Message
JulioTFP
7
Years of Service
User Offline
Joined: 5th Mar 2017
Location:
Posted: 8th Apr 2017 13:27 Edited at: 8th Apr 2017 13:29
Hello everyone, I used to programm in the past in DarkBasic Pro, a few months ago I purchased AppGameKit Basic and i'm getting mad with Text Commands.

I'm trying to do a game (2D) without external files. Only with Sprites created from simple colors and of course: text. My target is to do a Football Simulator (only text). But I have some troubles (text ID are arrays).

I now i'm using bad the command CreateText because it is in a loop. But my question is, it is posible to create text with an unique ID? The programm have a lot of lines but this is an example:



With this I can make a list of all the players. But this will create a lot of text. And If I want to delete some of it, it's is impossible. The new text will appear over the other. My first idea was to take out GOSUB DisplayOnce of the loop, but If I do that, I can't refresh it.

I now my Engligh is bad but I hope someone will understand my problem and call help me.

The all code if you want (you can press up, down and enter). As you can see, when you press enter, the new text appear over the oldest one. And it's no posibble to delete it.

CodeName
7
Years of Service
User Offline
Joined: 30th Dec 2016
Location:
Posted: 8th Apr 2017 14:20 Edited at: 8th Apr 2017 14:22
You have to call Gosub out of the main loop.. Right before the Do Sync() Loop call it.

Or it will just go right back and create more text...

//out of the loop..
Gosub DisplayOnce

DO
//GOSUB DisplayOnce
SYNC()
LOOP

DisplayOnce:

RETURN
JulioTFP
7
Years of Service
User Offline
Joined: 5th Mar 2017
Location:
Posted: 8th Apr 2017 18:00
That's what I tried in first place. But if I do that, the I can't using this text and change it. Because i need a loop to change the text press the keys.

This is an example of changing that:



You can try to execute it, and execute the one of the first post and you will see the diference. May be should I restart all and trying to do it in a different way.

Thank you a lot for you answer.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Apr 2017 23:09
i split it in 3 parts
create id
useing id
delete id
you can use a type (struct) with variables to hold this id data, you can return it as result from function , of give it a function with ref keyword in parameter.
https://www.appgamekit.com/documentation/guides/12_array_changes.htm
AGK (Steam) V2017.03.31 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Apr 2017 23:21
You need to learn how to structure your code. You're trying to do everything in the main loop. Text objects will work like a sprite, you don't have to position it or draw it every cycle in the loop.

Create a separate part to create your text object and call it before the main loop. Then in your loop you can have the part that changes the text.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
CodeName
7
Years of Service
User Offline
Joined: 30th Dec 2016
Location:
Posted: 9th Apr 2017 04:57 Edited at: 9th Apr 2017 05:03
I would think to create a button and if it were pressed then enter the create text loop..

Up and down keys to select a .name by changing the values of the array. Even if the array .name has yet to be entered. Default .name of "Enter Name"

Make the exit of the loop when you hit the enter key.
JulioTFP
7
Years of Service
User Offline
Joined: 5th Mar 2017
Location:
Posted: 9th Apr 2017 09:10 Edited at: 9th Apr 2017 11:03
Thanks a lot! This afternoon ill try to fix the problem.

Edit:

Finally i did it changing the way of assignment ids. The text is always the same so I choose an unique id number of all the text. I will use rem to control all of them. Thanks a lot again.




I'm too used to DarkBasic way :cry:

Login to post a reply

Server time is: 2024-11-24 16:33:23
Your offset time is: 2024-11-24 16:33:23