Oct 6, 2011 07:28 PM
(This post was last modified: Oct 6, 2011 07:30 PM by Eternal Darkness.)
(Oct 6, 2011 07:05 PM)scarfacekilla Wrote: Ok then i have some questions - maybe VB .NET is handling this different to what i would expect and how C# is doing:
here you assign a string to a
here you call a method with parameter a and you use the return value of the method for the messagebox
Code MsgBox(Decisions(a))
here you assign b with k, which is "A wild walka" (local copy of the parameter)
Code Public Function Decisions(ByVal k As String) As String
b = k //local copy of the full string ?!
i dont know if the compiler handles = in if statements as == (equals) operator and not as ASSIGN = ... lets pretend it does a comparison
you test for "A wild walka"="A" OR "A wild walka"="E" .. etc
which is wrong... you want to check the enemies name...and therefore the first character of its name... like b="ape" ... b[0]=="a" OR... etc..
or am i wrong and the VB.NET compiler is that smart and does it automatically?!
Code If b = "A" Or b = "E" Or b = "I" Or b = "O" Or b = "U" Then
As I said at the top of the code
Code Dim a As String 'Characters name
So with 'b' as the characters name it will check the first letter of the string (string a). Strings and Characters can be converted easily to one another...
For Example...
Its not "A wild walka" = "A", it's rather if the first character in the sting a (characters name) has a "A" as the first letter, then return an.
Console.Write(Decisions(a) & a)
I post my opinions, please try not to be offended... I am not saying I am superior, but my interpretation of what you are saying may be befuddling.
I still think my code is simpler :)
Nuff' with the arguing guys <3
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
██ 📿 🔮 🫀 ⚡️ 🥣 ██
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
(Oct 6, 2011 07:56 PM)Local Celeb Wrote: I still think my code is simpler :)
Nuff' with the arguing guys <3
wasn arguing, i was confused bc i read the code with c# .NET thinking and if u look at the code out of this view it's wrong, that's why i asked a second time and explained where the points are which are strange in my eyes ..
ur code is simpler thats right but:
1. U are everytime initializing the aeiou array which is memory waste - this array never changes, so make it global & static
2. You are using a string array, which is again waste, because all you actually need is a char array
3. Create a static list and use contains - SHORTEST, SIMPLEST
Code private static IList<char> aeiou = new List<char>{ 'a','e','i','o','u'}
public static string AorAN(string text)
{
//you should do some checks on text if it's null/empty etc.
//otherwise it will crash on the next line if it's null or string.Empty;
return aieou.Contains(text[0].ToLower()) ? "An" : "A";
}
P.S. When is the reposirty up, wanna have a look at your code :)
I have a download up there right now :)
It's towards the bottom of the post.
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
██ 📿 🔮 🫀 ⚡️ 🥣 ██
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
Oct 8, 2011 07:53 AM
(This post was last modified: Oct 8, 2011 07:53 AM by Eternal Darkness.)
(Oct 7, 2011 03:14 AM)Local Celeb Wrote: I have a download up there right now :)
It's towards the bottom of the post.
Imma look at it. :)
(Oct 6, 2011 07:56 PM)Local Celeb Wrote: I still think my code is simpler :)
Nuff' with the arguing guys <3
Whatever floats your boat bro, it took a few sec to code. Wasn't expecting it to be used as is... Just was trying to give a simple example with my 'you should add this' comment.
Sorry for arguing in your thread bro, just had to cover my butt a bit. :l
I post my opinions, please try not to be offended... I am not saying I am superior, but my interpretation of what you are saying may be befuddling.
It's all good man. I've got some more work done on the framework; but I'm gonna play WoW and upload it later
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
██ 📿 🔮 🫀 ⚡️ 🥣 ██
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
Code Math.Round(Number, 0, MidpointRounding.AwayFromZero); // you should have a look at this function and the parameters
otherwise...why so complicated, this should also work
Code public static Double GreaterPoint5(Double Number)
{
var i = Number - Convert.ToInt32(Number);//should get rid of the full number
return i >=.5 ? Math.Ceiling(Number) : Math.Floor(Number);
}
You should change your General class and its functions to static...why? because that's their purpose :-D
another thing you should learn/read is inheritance and abstract classes ...
weapons, potions, armor (if you want even enemies and the player) are objects which will have some basic information which they share like "Name"
then you do something like Item:WorldObject, Weapon:Item, Sword:Weapon (if you want swords to have specific attributes and others than Axes or Bows)...
Same for Players and Enemies.... Character:WorldObject, NPC:Character, Player:Character etc.
you will save a lot of redundant code and trouble...i had just a quick look....
your code logic is twisted, you item class inherits from player, which makes now sense ?!
I have no previous experience of doing something like this; I'll get right on learning that :)
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
██ 📿 🔮 🫀 ⚡️ 🥣 ██
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
just a quick example
Code /// <summary>
/// Basic class which describes any object in the world
/// </summary>
public class WorldObject
{
public string Name { get; set; }
public string Description { get; set; }
/// <summary>
///
/// </summary>
/// <param name="name"><b>Name:</b> Sets the Name of the Object</param>
/// <param name="description"><b>Description:</b> Sets the Description for the Object</param>
public WorldObject(string name = "", string description = "")
{
Name = name;
Description = description;
}
}
public class Item : WorldObject
{
public bool CanBeStacked { get; set; }
public bool CanBeUsed { get; set; }
public decimal Weight { get; set; }
public decimal Amount { get; set; }
public decimal Value { get; set; }
public Item(string name = "null", string description = "null", decimal weight = 1, decimal amount = 1,
decimal value = 0) : base(name, description)
{
Weight = weight;
Amount = amount;
Value = value;
}
}
public class Character : WorldObject
{
public int Level { get; set; }
public decimal Strength { get; set; }
public decimal Dextery { get; set; }
public decimal MaxHealth { get; set; }
public decimal CurrentHealth { get; set; }
public delegate void DeathEventHandler(object sender, EventArgs e);
public event DeathEventHandler Died;
public Character()
{
//whatever
}
/// <summary>
///
/// </summary>
/// <param name="enemy">reference of the enemy who is attacking</param>
public virtual void DealDamage(ref Character enemy) //virtual so you can overwrite it for your player if you want, or do some BASIC calculation for baisc enemies/players and more advanced for Bosses or special...
{
//here you write somelogic, if the enemy successfully attacked
//this. defendet or counter attacked etc.
CurrentHealth -= enemy.Strength;
if(CurrentHealth<=0)
{
Died(this, null);//this will raise the event that this player/npc, died
}
}
}
[Flags]//you can list all you effects/buffs/debuffs here, or you can have several enums for "elemets", "buffs","debuffs", i choose this because with flags
//you can do combinations...but you you need to calculate it out for example the value of fire+resitence needs to be unique for FireResistance
public enum EffectName
{
None=0x000,
Heal=0x001,
Revive=0x002,
Death=0x004,
Resistence=0x008,
Absorb=0x010,
Fire=0x020,
FireResitance = 0x028,
Ice=0x03F
}
/// <summary>
///
/// </summary>
public class FirePotion : Item
{
/// <summary>
///
/// </summary>
public EffectName PotionEffect = EffectName.Fire | EffectName.Resistence; //which will be FireResitance
}
(Oct 9, 2011 04:13 PM)Local Celeb Wrote: I have no previous experience of doing something like this; I'll get right on learning that :)
that's why i mentioned that i would like to help :)
there are lot's of little things if you do them or correct them right now you will save a lot of time later :)
there are some RPG XNA tutorials which you should read, even if you don't use XNA ... it gives you some good training
You should add folder structure like:
Project
|___Enums
| |____Classes (mage, warrior etc)
| |____Elements (Fire, Wind, Ice etc)
|
|___Items
| |___Weapons
| | |___Swords
| | | |_Katana
| | |
| | |___Axes
| |
| |___Potions
etc..
use auto properties where possible!
the naming guideline in C# is variables camel case and properties Pascal case ( http://www.akadia.com/services/naming_conventions.html)
try to use events for things like "level up" , "death"...
i dont know if its because its unfinished but you dont use some variables in your formulas but you define them
and your attack formula is very confusing, because in the end you check the final damage > minDamage and you add 1 until its more than min damage and or you return a random number between 1 and 10...
what the heck? ... if you do a correct calculation of the damage you deal you dont need any while to add 1 until is more than min damage...
if you had planed it more carefully you would say: if my calculation returns less then the expected min damage, return min damage (and not add value x until dmg is >= minDamage.. and even then!!! you should add the difference between the calculated dmg and then min damage and not add 1 in a loop....)
you should do first a specification plan everything and afterwards start developing.. like i said you inherit from the wrong classes etc.
and rewrite the whole thing while it's still possible
have a look at: http://www.freewebs.com/campelmxna/tutorials.htm and http://sourceforge.net/projects/console-rpg/
Oct 10, 2011 06:29 AM
(This post was last modified: Oct 10, 2011 06:32 AM by Local Celeb.)
Actually, I think I'm done with this project.
I've learned some from it but I guess I'm not ready for game programming :/
I may continue it sometime but not right now. I need to get better.
Edit :
I'm going to take your advice and read up on some stuff.
Also when I check for that final> min, I generate a random number between the min and the final to give the damage.
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
██ 📿 🔮 🫀 ⚡️ 🥣 ██
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
Hey I didnt want you to scare you off the project.. i just know from my own experience that if you do it kinda messy at the beginning you will have lot of trouble/problems later fixing things
or read your own code :) i am currently working on a project and have already over 20.000 lines of code, if i would not have any folder structure I would be lost :)
or if i would not use some of the inheritance i would have to change things like at 20 places, but now just in 1 :)
There is a good XNA RPG tutorial which you should work throu, it uses 2D engine BUT you can convert it almost 1 to 1 into a console text based RPG..
and it's pretty good for starters, to get your first "framework" going. One important thing you missed is a "GameScreens(Handler)" Class
or Input class (of course the input works different in XNA/Console) but even in your game u need to take input from the user at several places...and once programmed as a (static) inputhandler class, you don't need to worry anymore for wrong input etc.
Your task should be to fix up your project and finish it :)
But yes, to accomplish that you need to read tutorials to get a better understanding of game concept etc.
the tutorial i was talking about:
http://xnagpa.net/rpgtutorials.html <<its for the older 3.x XNA framework
http://xnagpa.net/xna4rpg.php <<for XNA 4.0
|