Changing the Font in the Console & My First new game.
- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
Awesome!
With a new program called FONY and by modifying the registry I was able to get my custom font working within the Windows command prompt. But for some reason it overwrote the Terminal font and it still won't appear in the Font tab within the console. Luckily I kept a backup of the Terminal font from a earlier modification attempt. I'm very close to getting this working.
With a new program called FONY and by modifying the registry I was able to get my custom font working within the Windows command prompt. But for some reason it overwrote the Terminal font and it still won't appear in the Font tab within the console. Luckily I kept a backup of the Terminal font from a earlier modification attempt. I'm very close to getting this working.
Re: Changing the Font in the Console & My First new game.
Great! I really want to try this game.
- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
I finally got it working. But you have to manually select the font in the console window, for some reason my PB code still isn't able to reference it.
My issue before was caused by me attempting to load a .fon file into the registry where it was expecting a .tff font file. So then I tried logically adding the .fon file into where Rasterfonts are stored. But after setting the value this caused my font to override the standard "Terminal" font after restarting my computer. Finally I gave up on using .fon files after several attempts and tried making a it into a .TFF which then worked.
I am also considering using Binary data to show the graphics instead of loading a font, but I will need to do more research on how to do it. I found one thing so far on converting sprites into Hex data: https://www.ticalc.org/archives/files/f ... 38904.html
The major hurdle if I continue to use fonts is the software and workflow. I prefer a bitmap/pixel based utility like FONY. But it only allows for export of .FON so in order to make a True Type fond using pixels I have an online editor called Bitfontmaker2, but it limits characters to 14 pixels wide... (My goal is 32x32) Yet another program I tried called Type 3 is very nice and full featured but you draw things using vector lines, which is not so great for creating game sprites... So I'm currently hunting for better software.
Here is the game as it stands, my next major update should feature the sprite graphics.




My issue before was caused by me attempting to load a .fon file into the registry where it was expecting a .tff font file. So then I tried logically adding the .fon file into where Rasterfonts are stored. But after setting the value this caused my font to override the standard "Terminal" font after restarting my computer. Finally I gave up on using .fon files after several attempts and tried making a it into a .TFF which then worked.
I am also considering using Binary data to show the graphics instead of loading a font, but I will need to do more research on how to do it. I found one thing so far on converting sprites into Hex data: https://www.ticalc.org/archives/files/f ... 38904.html
The major hurdle if I continue to use fonts is the software and workflow. I prefer a bitmap/pixel based utility like FONY. But it only allows for export of .FON so in order to make a True Type fond using pixels I have an online editor called Bitfontmaker2, but it limits characters to 14 pixels wide... (My goal is 32x32) Yet another program I tried called Type 3 is very nice and full featured but you draw things using vector lines, which is not so great for creating game sprites... So I'm currently hunting for better software.
Here is the game as it stands, my next major update should feature the sprite graphics.




- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
I don't understand this error. All I've done is changed some "IF" statements into "CASE" and everything runs as normal until it gets to the end of the procedure.
[ERROR] player_creation.pb (Line: 1879)
[ERROR] Invalid memory access. (read error at address 0)
The Program execution has finished.

This procedure is referenced in my main file. Nothing has changed here other than I merged the SkillTraits() code into the CharacterCreate() file.

Previously it was crashing here until I changed String$ = Input into Question3.s{1} = Input(). I normally use String$ = Input anytime I want to return a basic "yes or no" from the users.
I use the same String$ = Input at least 30 times in my code and override the value when its called. Not sure why now its giving me issues???

*Edit* I tried placing the procedure in the main file and it gave me the same String error!

[ERROR] player_creation.pb (Line: 1879)
[ERROR] Invalid memory access. (read error at address 0)
The Program execution has finished.

This procedure is referenced in my main file. Nothing has changed here other than I merged the SkillTraits() code into the CharacterCreate() file.

Previously it was crashing here until I changed String$ = Input into Question3.s{1} = Input(). I normally use String$ = Input anytime I want to return a basic "yes or no" from the users.
I use the same String$ = Input at least 30 times in my code and override the value when its called. Not sure why now its giving me issues???

*Edit* I tried placing the procedure in the main file and it gave me the same String error!

Last edited by Vernostonos on Thu Jul 16, 2020 9:21 pm, edited 1 time in total.
Re: Changing the Font in the Console & My First new game.
I see a number of GOTO's in your code and if you changed your IF to CASE then you probably now have GOTO's in your SELECT/ENDSELECT blocks which is a big no-no 
PureBasic Help File...

PureBasic Help File...
Syntax
Goto <label>
Description
This command is used to transfer the program directly to the labels position. Be cautious when using this function, as incorrect use could cause a program to crash...
Note: To exit a loop safely, you always must use Break instead of Goto, and never use it inside a Select/EndSelect block (Unless you have the ability to manage the stack yourself, correctly.)
- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
Oh fudge.... 
But all the Goto's are contained within the procedure. I thought I made sure of that? I don't even have a real loop, literally one thing happens at a time.
Here is the offending area of code. I'm unsure how to use the BREAK statement.


But all the Goto's are contained within the procedure. I thought I made sure of that? I don't even have a real loop, literally one thing happens at a time.
Here is the offending area of code. I'm unsure how to use the BREAK statement.


Re: Changing the Font in the Console & My First new game.
In general:
Simply don't use Goto
Your screenshots are not really helpfull, because I don't 'copy' them to real code lines to test and show you something.
And I would prefer
to detect an one key answer.
So I can not enter sentences and I don't need to press CR.
Simply don't use Goto

Your screenshots are not really helpfull, because I don't 'copy' them to real code lines to test and show you something.
And I would prefer
Code: Select all
Repeat
Key$ = Inkey()
Delay(10)
Until Key$ <> ""
So I can not enter sentences and I don't need to press CR.
Last edited by infratec on Thu Jul 16, 2020 10:30 pm, edited 2 times in total.
Re: Changing the Font in the Console & My First new game.
Without a loop break is not needed.Vernostonos wrote:Oh fudge....
But all the Goto's are contained within the procedure. I thought I made sure of that? I don't even have a real loop, literally one thing happens at a time.
Here is the offending area of code. I'm unsure how to use the BREAK statement.![]()
...
I personally never ever use Goto but i dont see anything that looks wrong.
I only can offer a simpler way to check for the result of a question:
Code: Select all
If Bool(UCase(Input()) = "Y")
Goto AdjustAttributes_Main
Else
Goto EndSelectingStats
EndIf
Re: Changing the Font in the Console & My First new game.
May be something like that:
Code: Select all
EnableExplicit
Procedure.s GetKey()
Protected Key$
Repeat
Key$ = Inkey()
If key$ = ""
If RawKey()
Break
Else
Delay(10)
EndIf
EndIf
Until Key$ <> ""
ProcedureReturn Key$
EndProcedure
Define Key$
OpenConsole()
Repeat
Key$ = GetKey()
Debug Key$
Until Key$ = #ESC$
Re: Changing the Font in the Console & My First new game.
It's good to see the progress of your game.
I have just some comment and a handful of suggestions. Avoiding the use of Goto will help keep your program from being tangled up in knots. Follow the help file's advice and don't use Goto's within Select/Case/EndSelect constructs.
Many uses of Goto are to skip over code, reuse portions, or simply to enter/exit loops. Reuse can be done through the use of procedures (exiting from a procedure can be done with ProcedureReturn at multiple points if needed). Skipping over code can be done with If/Else/Endif setups where alternate branches meet up at the next point afterwards. Looping can be done with Repeat/Until, While/Wend and exited when conditions are set. Further the flow in loops can be modifed with the use of Break to exit early and Continue to immediately start the next round in the loop. These are all suggestions, use them or not according to your needs.
Another suggestion that you find helpful and to help maintain the flow of your code is the use of a kind of game state system. This is where you would have a central loop that examines the game state and executes procedures before returning to examine the next game state. Each procedure would modify the game state as a means of branching to different parts of the code and then exiting back to the main loop. The loop would basically have either a Select/Case/Endif with Cases for each state or If/ElseIF/Endif for each case.
Doing things in this manner would allow you to use simpler names for local protected variables in procedures without having to keep coming up with unique names for common things (i.e. question1$, question2$, question99$). It would also allow you to improve the individual procedures without having to untangle things and then re-entangle them to deal with each new change.
You could have a overall game state loop for the program and then smaller sub-loops for sub-menus.
I see you have implemented a system of If/ElseIF/EndIf system for your menues and for handling game states at the moment. The more you can standardize the way these things are executed and at the same time reduce what you have to remember the better.
Even if you ignore the previous ramblings, welcome to the forum.
It's good to see a new face and someone who likes to work on a programming project to see what's possible and to challenge themselves a little.
I have just some comment and a handful of suggestions. Avoiding the use of Goto will help keep your program from being tangled up in knots. Follow the help file's advice and don't use Goto's within Select/Case/EndSelect constructs.
Many uses of Goto are to skip over code, reuse portions, or simply to enter/exit loops. Reuse can be done through the use of procedures (exiting from a procedure can be done with ProcedureReturn at multiple points if needed). Skipping over code can be done with If/Else/Endif setups where alternate branches meet up at the next point afterwards. Looping can be done with Repeat/Until, While/Wend and exited when conditions are set. Further the flow in loops can be modifed with the use of Break to exit early and Continue to immediately start the next round in the loop. These are all suggestions, use them or not according to your needs.
Another suggestion that you find helpful and to help maintain the flow of your code is the use of a kind of game state system. This is where you would have a central loop that examines the game state and executes procedures before returning to examine the next game state. Each procedure would modify the game state as a means of branching to different parts of the code and then exiting back to the main loop. The loop would basically have either a Select/Case/Endif with Cases for each state or If/ElseIF/Endif for each case.
Doing things in this manner would allow you to use simpler names for local protected variables in procedures without having to keep coming up with unique names for common things (i.e. question1$, question2$, question99$). It would also allow you to improve the individual procedures without having to untangle things and then re-entangle them to deal with each new change.
You could have a overall game state loop for the program and then smaller sub-loops for sub-menus.
I see you have implemented a system of If/ElseIF/EndIf system for your menues and for handling game states at the moment. The more you can standardize the way these things are executed and at the same time reduce what you have to remember the better.
Even if you ignore the previous ramblings, welcome to the forum.

- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
I am thankful for all the help and suggestions. My methods certainly do need to improve, I will work on creating a master loop and more procedures.
I changed a few of the local variables from sharing String$ = Input() into Question1$ = Input() because I initially thought it was the cause of my error. That somehow I either had a logic error in my code or it was carrying over a variable into the next prompt and causing the crash.
I changed a few of the local variables from sharing String$ = Input() into Question1$ = Input() because I initially thought it was the cause of my error. That somehow I either had a logic error in my code or it was carrying over a variable into the next prompt and causing the crash.
Re: Changing the Font in the Console & My First new game.
Small example for a 'state machine"
Code: Select all
EnableExplicit
Enumeration 1
#Intro
#MainMenu
#Settings
#Leave
#Exit
EndEnumeration
Structure GameStructure
Player$
EndStructure
Procedure.s WaitForKey()
Protected Key$
Repeat
Key$ = Inkey()
If key$ = ""
If RawKey()
Break
Else
Delay(10)
EndIf
EndIf
Until Key$ <> ""
ProcedureReturn Key$
EndProcedure
Procedure Intro()
Protected Timeout.i, Key$, State.i
ConsoleLocate(0, 0)
PrintN (" ┌────────────────────────────────────────────────────────────────────────────┐")
PrintN (" │ **** Test Intro **** │")
PrintN (" └────────────────────────────────────────────────────────────────────────────┘")
Timeout = 100
ConsoleLocate(1, 20)
Print("Press any key for the main menu")
Repeat
ConsoleLocate(10, 10)
Select state
Case 0
Print("-")
State + 1
Case 1
Print("\")
State + 1
Case 2
Print("|")
State + 1
Case 3
Print("/")
State + 1
Case 4
Print("-")
State + 1
Case 5
Print("\")
State + 1
Case 6
Print("|")
State + 1
Case 7
Print("/")
State = 0
EndSelect
Delay(100)
Timeout - 1
If Inkey() <> ""
Timeout = 0
EndIf
Until Timeout = 0
ConsoleLocate(10, 10)
Print("")
ConsoleLocate(1, 20)
Print(" ")
EndProcedure
Procedure.i MainMenu()
Protected Result.i
ConsoleLocate(0, 0)
PrintN (" ┌────────────────────────────────────────────────────────────────────────────┐")
PrintN (" │ **** Main menu **** │")
PrintN (" └────────────────────────────────────────────────────────────────────────────┘")
ConsoleLocate(10, 10)
Print("I : Intro")
ConsoleLocate(10, 12)
Print("S : Settings")
ConsoleLocate(10, 14)
Print("E : Exit")
Repeat
Select WaitForKey()
Case "i"
Result = #Intro
Case "s"
Result = #Settings
Case "e", #ESC$
Result = #Leave
EndSelect
Until Result
ConsoleLocate(10, 10)
Print(" ")
ConsoleLocate(10, 12)
Print(" ")
ConsoleLocate(10, 14)
Print(" ")
ProcedureReturn Result
EndProcedure
Procedure Settings(*Game.GameStructure)
ConsoleLocate(10, 10)
Print("Username: ")
ConsoleCursor(1)
*Game\Player$ = Input()
ConsoleCursor(0)
ConsoleLocate(10, 10)
Print(" ")
EndProcedure
Procedure Leave(*Game.GameStructure)
Protected Timeout.i
ConsoleLocate(10, 10)
Print("Bye " + *Game\Player$)
Timeout = 50
Repeat
Delay(100)
Timeout - 1
If Inkey() <> ""
Timeout = 0
EndIf
Until Timeout = 0
EndProcedure
Define.i State
Define Game.GameStructure
If OpenConsole("State test")
EnableGraphicalConsole(1)
ClearConsole()
ConsoleCursor(0)
State = #Intro
Repeat
Select State
Case #Intro
Intro()
State = #MainMenu
Case #MainMenu
State = MainMenu()
Case #Settings
Settings(@Game)
State = #MainMenu
Case #Leave
Leave(@Game)
State = #Exit
EndSelect
Until State = #Exit
EnableGraphicalConsole(0)
ConsoleCursor(1)
ClearConsole()
CloseConsole()
EndIf
- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
Thanks Infratec!!!!
This is a lot better than my own attempt, I will put it to good use.

This is a lot better than my own attempt, I will put it to good use.
- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
I've begun working on defining the character classes and would like some input on what to include.
The job categories are broken up into 3 different sectors:

When you select a career/job this is what your character becomes before the War occurs:

I don't know how serious I am about some of these professions, but the more choices the better I think!
Once you choose a profession your level of skill within that field is determined by how many years pass before Judgement Day occurs. (This is randomized)
Characters that are older will find themselves more skilled but possibly suffer a slight degradation in physical attributes beyond a certain age.
The same occurs in reverse, where the younger you are the less skilled you will be but overall healthier.
You will be able to assign some Skill Traits manually and attributes based upon the random roll of the dice.
But you will not be able to max all of your stats to 15, this would make the game way too easy.
Choosing a job also helps to determine what your starting items, equipment, car, etc will be. Much of this is also randomized.
I plan to implement a save system but also offer a "Roguelike" difficulty which enforces perma death.
Obviously I think most people will go for Military based builds regarding their character, which offers the most combat oriented perks. Ppersonally I love the idea of a Janitor surviving nuclear war, to re-hone his skills and become a badass within the wasteland. Let me know what you guys think.
The job categories are broken up into 3 different sectors:

When you select a career/job this is what your character becomes before the War occurs:

I don't know how serious I am about some of these professions, but the more choices the better I think!
Once you choose a profession your level of skill within that field is determined by how many years pass before Judgement Day occurs. (This is randomized)
Characters that are older will find themselves more skilled but possibly suffer a slight degradation in physical attributes beyond a certain age.
The same occurs in reverse, where the younger you are the less skilled you will be but overall healthier.
You will be able to assign some Skill Traits manually and attributes based upon the random roll of the dice.
But you will not be able to max all of your stats to 15, this would make the game way too easy.
Choosing a job also helps to determine what your starting items, equipment, car, etc will be. Much of this is also randomized.
I plan to implement a save system but also offer a "Roguelike" difficulty which enforces perma death.
Obviously I think most people will go for Military based builds regarding their character, which offers the most combat oriented perks. Ppersonally I love the idea of a Janitor surviving nuclear war, to re-hone his skills and become a badass within the wasteland. Let me know what you guys think.
- Vernostonos
- User
- Posts: 61
- Joined: Thu Jul 02, 2020 9:52 pm
Re: Changing the Font in the Console & My First new game.
My battle engine is almost complete but for some reason enemies can occasionally receive two handed weapons in their left hand. This is not supposed to happen, does this excerpt of my code seem logical? It passes the values correctly to the right and left hand, but when a two handed weapon is selected for the left hand it ignores the global called "Hands_req". The Hands_req is the container for how many hands the selected weapon requires. I had a lot of scope issues when coding this but I eventually figured out the correct order. It does work as intended if the Right handed weapon is 2 handed, thus skipping the Until loop...
Enemy_Randomize_Attrib() - This randomizes the physical attributes of the enemy.
DisplayEnemy_Attrib() - This draws the above values to the screen.
Display_Enemy_PossibleWeapons() - This shows the categories of weapons the selected enemy can choose from.
Randomize_Enemy_Weapon_Selection() - This randomizes the weapons based upon the allowed categories for this enemy type.
Set_Enemy_Weapons() - This is what stores the list of items.
The procedures above basically work like this:
Everything works except for it passing 2 handed weapons when it shouldn't. I must have either a logic error or the value is somehow not in scope?
Code: Select all
Enemy_Randomize_Attrib()
DisplayEnemy_Attrib()
Display_Enemy_PossibleWeapons()
Randomize_Enemy_Weapon_Selection()
Set_Enemy_Weapons()
PrintN(" ========================================================")
PrintN(" Enemy #1 Category: > "+WPN_Catagory+" < 1st Weapon: > "+WPN_name+" <")
PrintN(" ========================================================")
Display_Selected_Weapon()
If Enemy1_Righthand = #Empty$
Enemy1_Righthand = WPN_name
EndIf
If Hands_req = 2
Enemy1_Lefthand = Enemy1_Righthand
Goto Skip_LHand_E1
EndIf
If Enemy1_Lefthand = #Empty$
Repeat
Randomize_Enemy_Weapon_Selection()
Until Hands_req = 1 And WPN_name <> #Empty$
Set_Enemy_Weapons()
PrintN(" ========================================================")
PrintN(" Enemy #1 Category: > "+WPN_Catagory+" < 2nd Weapon: > "+WPN_name+" <")
PrintN(" ========================================================")
Display_Selected_Weapon()
PrintN(" HANDS VALUE IS:"+Hands_req+"")
Enemy1_Lefthand = WPN_name
EndIf
Skip_LHand_E1:
DisplayEnemy_Attrib() - This draws the above values to the screen.
Display_Enemy_PossibleWeapons() - This shows the categories of weapons the selected enemy can choose from.
Randomize_Enemy_Weapon_Selection() - This randomizes the weapons based upon the allowed categories for this enemy type.
Set_Enemy_Weapons() - This is what stores the list of items.
The procedures above basically work like this:
Code: Select all
If Result = #smallguns And Enemy_CanUse_smallguns = #True
WPN_Catagory = "Smallguns"
ElseIf WPN_Catagory = "Smallguns"
Result = Random(34,31);Pick between these weapons
If Result = #CrudePipePistol ;31
WPN_Selected = #CrudePipePistol
EndIf
If Result = #Revolver;32
WPN_Selected = #Revolver
EndIf
If Result = #RareRevolver;33
WPN_Selected = #RareRevolver
EndIf
If Result = #BerretaM9Pistol;34
WPN_Selected = #BerretaM9Pistol
EndIf
WPN_Selected = #Revolver ;And WPN_Catagory = "Small Guns" And Enemy_CanUse_smallguns = #True
WPN_name ="Revolver"
WPN_desc ="A very old and worn small Revolver."
Atk_Variety = 1
Damage_type1 ="Kinnetic"
Damage_type2 = #Empty$
Damage_Mx = 18
Damage_Mn = 10
APcost = 2
WPNRange = 60
ThrwWPNRange = 0
Min_ST = 1
Ammunition ="bullets"
Hands_req = 1
Magazine_Size = 6
Value = 15
Item_lb = 2
Code: Select all
If Enemy1_Lefthand = #Empty$
Repeat
Randomize_Enemy_Weapon_Selection()
Until Hands_req = 1 And WPN_name <> #Empty$
Set_Enemy_Weapons()