Mene-Mene

Member
Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
|
I'm rethinking of making a temporary PNR engine. Basically PNR - save function. A couple things need to be understood first though, first Class withing classes/Types within types. ex. Type Player wants to wear type Armor, I used to not have the armor affect Type Player, but now in order to do so, I need a type. Type Player field Gender$ type Garment field Name$ field Defense_Bonus end type field Defense end type
|
or something like, is that possible? One way I've tried to accomplish that is by Lists, but those didn't work either. type PlanetT field Name$ field Zones:TList end typeP:PlanetT = new PlanetT type ZoneT field Name$ end type Z:ZoneT = new ZoneT listaddlast Zones.P, Z:ZoneT
|
Secondly, about mindless minions. Basically say I need a random number of Stormtroopers to come in and assault the player between 1 and 100. Each stormtrooper would be an instance of a type. Unfortunetly if I Don't know how many stormies I"m going to make, how can I make the instance? I've tried:
for Loop_Var = 1 to num_Stormies Stormtroop:StormTrooperT = new StormTrooperT num_cur_Stormies++ nextfor Loop_Var = 1 to num_cur_Stormies Decide() Move() next function Decide() if X.StormTroop < 800 MoveX.StormTroop = true endif end function function Move() if MoveX.StormTroop = true X.StormTroop-- endif end function
|
But it didn't work. As for what language, pretty near any language will do for ideas, but if you want to be exact on functions available its in BM. ------------------ MM out- Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice. "Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto I reserve the full right to change my views/theories at any time. [This message has been edited by Mene-Mene (edited July 24, 2007).] |
samw3

Member
Posts: 542
From: Toccoa, GA, USA
Registered: 08-15-2006
|
What's PNR? Is this what you are trying to do? type Garment field Name$ field Defense_Bonus end type Type Player field Gender$ field Armor:Garment field Defense end type ------------------ Sam Washburn |
Mene-Mene

Member
Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
|
I must have thought I had already tried that. That's what I was thinking for most of the first question. PNR stands for Star Wars Protectors of the New Republic which is the name of one of my major projects. ------------------ MM out- Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice. "Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto I reserve the full right to change my views/theories at any time. |
samw3

Member
Posts: 542
From: Toccoa, GA, USA
Registered: 08-15-2006
|
Ah, ok. Good luck on the project. As for your second question, I would use an array that is big enough to hold all the stormtroopers with a num_cur_troopers, or you could use a TList. Array Version:
Local Stormtroop:StormTrooperT[num_Stormies] for Loop_Var = 1 to num_Stormies Stormtroop:StormTrooperT[Loop_Var] = new StormTrooperT num_cur_Stormies++ next for Loop_Var = 1 to num_cur_Stormies Decide(Loop_Var) Move(Loop_Var) next function Decide(i:Int) if X.StormTroop[i] < 800 MoveX.StormTroop[i] = true endif end function function Move(i:Int) if MoveX.StormTroop[i] = true X.StormTroop[i]-- endif ------------------ Sam Washburn |
Mene-Mene

Member
Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
|
by looking at your example it solved both problems. One I hadn't even gotten to asking about. A big part of my problem was I didn't know how to define a type array. I was using StormTroop[num_Stormies]:StormTrooperT when I should have been using StormTroop:StormTroopT[num_stormies] Awesome! BTW, num_cur_Stormies++ doesn't exist in BM, I just said that for ease of use. ------------------ MM out- Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice. "Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto I reserve the full right to change my views/theories at any time. |
Mene-Mene

Member
Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
|
Alright I"m back again with PNR. I'm curious as to what the main route for a game loop would be in a multi-location game. Would you create different functions for each location, or a if statement and cover them all in a single function, how would you go about it? BTW, for those interested, here's the current code:
'First the elements, garments, armor, ext. Type TGarment Field Name$ End TypeType THouse Field Name$ Field Storage Field Clothing:TGarment[5] 'Note:Change when you get more/less garments. Field Furniture 'Explore Later Field Refrigerator 'Explore Later Field Cost End Type Type TWeapon Field Name$ Field Strength End Type Type TItem Field Name$ Field TypeItem$ End Type Type TSkill Field Name$ Field Action$ Field Degree Field Cost End Type 'Then the smaller settings Type TZone Field Name$ Field Spawns$[1] End Type 'Then the large settings Type TPlanet Field Name$ Field Zones:TZone[2] End Type Type TSystem Field Name$ Field Planets:TPlanet[2] End Type 'Then the Characters Type TChar Field Name$ Field Gender$ Field Garment:TGarment[5] Field Profession$ Field Class 'Explore later Field Species$ Field System$ Field Planet$ Field Zone$ Field House:THouse 'This is Profession specific so the profession type will branch off. Field Attack Field Defense Field Life Field MaxLife Field Experience Field MaxExperience Field Level Field Feeling Field MaxFeeling Field TotalAttack Field TotalDefense Field NumWeapons Field Weapon:TWeapon[2] Field Items:TItem[50] Field Credits End Type Type TJedi Extends TChar Field LightsaberCombat Field ForcePowers Field BlockBlasterBolts Field ForceLightning Field Skills:TSkill Field SkillPool End Type 'Then Finally the Player Type TPlayer Field Name$ Field Characters:TChar[] Field NumCharacters End Type #SetStats SCorellian:TSystem = New TSystem SCorellian.Name$ = "Corellian" SCorellian.Planets[0] = New TPlanet SCorellian.Planets[1] = New TPlanet SCorellian.Planets[0].Name$ = "Corellia" SCorellian.Planets[0].Zones[0] = New TZone SCorellian.Planets[0].Zones[1] = New TZone SCorellian.Planets[0].Zones[0].Name$ = "Jedi Temple Ruins" SCorellian.Planets[0].Zones[0].Spawns[0] = "Battle Droid" #MainLoop Print "Hello welcome to Star Wars Protectors of the New Republic." choose$ = Input$("Would you like to create a character?") If Choose$ = "Yes" CreateCharacter() ElseIf Choose$ = "yes" CreateCharacter() ElseIf Choose$ = "No" LoadCharacter() ElseIf Choose$ = "no" LoadCharacter() ElseIf Choose$ = "Quit" End ElseIf Choose$ = "quit" End ElseIf Choose$ = "End" End ElseIf Choose$ = "end" End Else EndIf Function CreateCharacter() #Questions #ProfSet Prof$ = Input$("What is your character's profession?") If Prof$ = "Jedi" Then Char:TJedi = New TJedi Char.Profession$ = "Jedi" ElseIf Prof$ = "jedi" Then Char:TJedi = New TJedi Char.Profession$ = "Jedi" Else Print "Sorry, command not understood." Goto ProfSet EndIf 'Declare types Char.Weapon[0] = New TWeapon Char.Garment[0] = New TGarment #NameSet Char.Name$ = Input$("What is your character's name?") #GenderSet Gender$ = Input$("What is your character's gender?") If Gender = "Male" Char.Gender$ = "Male" ElseIf Gender = "male" Char.Gender$ = "Male" ElseIf Gender = "Female" Char.Gender$ = "Female" ElseIf Gender = "female" Char.Gender$ = "Female" Else Print "Sorry, command not understood." Goto GenderSet EndIf #GarmentSet Print "What's your Garment?" Print "Available: Robe" Garment$ = Input$("") If Garment$ = "Robe" Char.Garment[0].Name$ = "Robe" ElseIf Garment$ = "robe" Char.Garment[0].Name$ = "Robe" Else Print "Sorry, command not understood" EndIf 'Ask Class later #SpeciesSet Species$ = Input$("What is your character's species?") If Species = "Human" Char.Species$ = "Human" ElseIf Species = "human" Char.Species$ = "Human" Else Print "Sorry, command not understood." Goto SpeciesSet EndIf #SystemSet Print "What is your character's system?" Print "Choices include: Corellian" System$ = Input$("") If System = "Corellian" Char.System$ = "Corellian" ElseIf System = "corellian" Char.System$ = "Corellian" Else Print "Sorry, command not understood." Goto SystemSet EndIf #PlanetSet Print "What is your character's planet?" Print "Choices include: Corellia" Planet$ = Input$("") If Planet = "Corellia" Char.Planet$ = "Corellia" ElseIf Planet = "corellia" Char.Planet$ = "Corellia" Else Print "Sorry, command not understood." Goto PlanetSet EndIf #Settings If Char.Species = "Human" Char.Attack = 4 Char.Defense = 2 If Char.Profession = "Jedi" Char.LightsaberCombat = 2 Char.ForcePowers = 2 Char.BlockBlasterBolts = 2 Char.ForceLightning = 1 Char.Weapon[0].Name$ = "Lightsaber" Char.Weapon[0].Strength = 1 Char.Life = 150 Char.MaxLife = 150 Char.Feeling = 100 Char.MaxFeeling = 100 Char.Credits = 434 Char.Zone$ = "Jedi Temple Ruins" EndIf EndIf End Function Function LoadCharacter() #Questions #ProfSet Prof$ = Input$("What is your character's profession?") If Prof$ = "Jedi" Then Char:TJedi = New TJedi Char.Profession$ = "Jedi" ElseIf Prof$ = "jedi" Then Char:TJedi = New TJedi Char.Profession$ = "Jedi" Else Print "Sorry, command not understood." Goto ProfSet EndIf 'Declare types Char.Weapon[0] = New TWeapon Char.Weapon[1] = New TWeapon Char.Garment[0] = New TGarment Char.Garment[1] = New TGarment #NameSet Char.Name$ = Input$("What is your character's name?") #GenderSet Gender$ = Input$("What is your character's gender?") If Gender = "Male" Char.Gender$ = "Male" ElseIf Gender = "male" Char.Gender$ = "Male" ElseIf Gender = "Female" Char.Gender$ = "Female" ElseIf Gender = "female" Char.Gender$ = "Female" Else Print "Sorry, command not understood." Goto GenderSet EndIf #GarmentSet Garment$ = Input$("What is your character's garment?") If Garment$ = "Robe" Char.Garment[1].Name$ = "Robe" ElseIf Garment$ = "robe" Char.Garment[1].Name$ = "Robe" Else Print "Sorry, command not understood." Goto GarmentSet EndIf 'Ask Class later #SpeciesSet Species$ = Input$("What is your character's species?") If Species = "Human" Char.Species$ = "Human" ElseIf Species = "human" Char.Species$ = "Human" Else Print "Sorry, command not understood." Goto SpeciesSet EndIf #SystemSet System$ = Input$("What is your character's system?") If System = "Corellian" Char.System$ = "Corellian" ElseIf System = "corellian" Char.System$ = "Corellian" Else Print "Sorry, command not understood." Goto SystemSet EndIf #PlanetSet Planet$ = Input("What is your character's planet?") If Planet = "Corellia" Char.Planet$ = "Corellia" ElseIf Planet = "corellia" Char.Planet$ = "Corellia" Else Print "Sorry, command not understood." Goto PlanetSet EndIf #ZoneSet Zone$ = Input("What is your character's zone?") #Settings Attack$ = Input("What is your character's melee attack?") Char.Attack = Int(Attack$) Defense$ = Input("What is your character's melee defense?") Char.Defense = Int(Defense$) If Char.Profession = "Jedi" LightsaberCombat$ = Input$("What is your character's Lightsaber Combat?") Char.LightsaberCombat = Int(LightsaberCombat$) ForcePowers$ = Input$("What is your character's Force Powers?") Char.ForcePowers = Int(ForcePowers$) BlockBlasterBolts$ = Input$("What is your character's Block Blaster Bolts?") Char.BlockBlasterBolts = Int(BlockBlasterBolts$) ForceLightning$ = Input$("What is your character's Force Lightning?") Char.ForceLightning = Int(ForceLightning$) NumWeapons$ = Input$("How many weapons do you have equipped?") Char.NumWeapons = Int(NumWeapons$) If Char.NumWeapons = 2 Char.Weapon[0].Name$ = Input$("What weapon do you have in slot 1?") Strength1$ = Input$("How powerful is it?") Char.Weapon[0].Strength = Int(Strength1$) Char.Weapon[1].Name$ = Input$("What weapon do you have in slot 2?") Strength2$ = Input$("How powerful is it?") Char.Weapon[1].Strength = Int(Strength2$) ElseIf Char.NumWeapons = 1 Char.Weapon[0].Name$ = Input$("What weapon do you have equipped?") Strength$ = Input$("How powerful is it?") Char.Weapon[0].Strength = Int(Strength$) EndIf Life$ = Input$("What is your character's Life?") Char.Life = Int(Life$) MaxLife$ = Input$("What is your character's Max Life?") Char.MaxLife = Int(MaxLife$) Feeling$ = Input$("What is your character's Feeling?") Char.Feeling = Int(Feeling$) MaxFeeling$ = Input$("What is your character's Max Feeling?") Char.MaxFeeling = Int(MaxFeeling$) Credits$ = Input$("What is your character's credits?") Char.Credits = Int(Credits$) EndIf End Function
|
------------------ MM out- Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice. "Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto I reserve the full right to change my views/theories at any time. |
dartsman

Member
Posts: 484
From: Queensland, Australia
Registered: 03-16-2006
|
multi-location, such as different levels? with each level being a different location? Basically you just need to know what level/location the player is in and use that to determine which level/location to show. This would be best by using Abstraction style such as (excuse my French, I mean C++ :P I've never bothered with Blitz): Level *g_level = NULL;void ChangeLevel(Level *lvl) { g_level = lvl; } |
then in your Logic/Render loop you do: void Logic(float deltaTime) { // other logic // do level logic (can be where-ever you need this in your logic loop) if (g_level != NULL) g_level->Logic(deltaTime); } void Render() { if (g_level != NULL) g_level->Render(); } |
Note that when you use 'ChangeLevel()' on a new level object, you'll be pointing right at it... That way none of your code is riddled with too many if's. You don't even really need to do this using pointers either... A way you could do this is in blitz (if it doesn't support pointers or unable to do the method above), is to just use an indexed array. The player can just store an index value of what level/location they are in. This index value points directly at the array and then in the same manor as above you could do:
void ChangeLevel(int levelIndex) { player.levelIndex = levelIndex; } |
then in your Logic/Render loop you do: void Logic(float deltaTime) { // other logic // do level logic (can be where-ever you need this in your logic loop) levelArray[player.levelIndex].Logic(deltaTime); } void Render() { levelArray[player.levelIndex].Render(); } |
The only thing you might want to do is create a 'ValidLevel' or 'ValidLocation' function, which can be checked before calling functions such as Logic() or Render(): if (ValidLevel(player.levelIndex)) { levelArray[player.levelIndex].Render(); } |
Note: you would only want to pass in the levelIndex to make sure that it fits the size of the array within the ValidLevel function (to make sure levelIndex fits the bounds of the array). So ValidLevel would looks something like: bool ValidLevel(int levelIndex) { // check the bounds of the array if (levelIndex < 0 || levelIndex >= levelArray.size()) { return false; } // do other checks (the level itself might store some boolean which might say if the level has been loaded or the like, check those sorts of things) // all checks are fine, so the level is assumed 'valid'. return true; } |
I hope that was what you were asking, otherwise, I'm sure it'll give you some ideas or someone else some ideas... the main thing to note is that the levels will be closely the functionality, so if your able to store an array/list of the level you'll only need to make sure your looking at the right one... anywho, hope that helped... ------------------ jonwarner.net |
Mene-Mene

Member
Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
|
Remember, this is a TEXT RPG, anyway, the problem isn't storing the information, the problem is setting the spawns and stuff for the location. Ex. Previous Method:
function JediTempleRuins() randomnumber = rand(1,5) if randomnumber = 1 Battle() else move$ = input("You see a dark chamber, what do you do?") if move$ = "north" UpperCityNorth() elseif move$ = "south UpperCitySouth() else JediTempleRuins() endif endif
|
That kind of Idea, basically determining what goes on in each different level, and say in Jedi Temple Ruins Zone on Planet Corellia in the Corellian System you might meet thieves, while in the Upper City East, you might be Assassins, so the things to watch for, the sights, and such will be different, and idk how to handle that. ------------------ MM out- Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice. "Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto I reserve the full right to change my views/theories at any time.
[This message has been edited by Mene-Mene (edited July 29, 2007).] |