ā Implement local players using a single button in Windows Forms bowling game
Csharp!!!
36 Replies
okay, so, how do you currently track the players score/stats/whatever?
I havent created the most sophistiaced way to do that, i just write it in and dont mess with it
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/should i post my whole thing?
sure
BlazeBin - tmnoirhpfumg
A tool for sharing your source code with the world!
How the UI looks like currently
Ah okay, so its a bowling score calculation app more or less
Basically
so, currently your entire program runs its logic when you press that button "Calculate Score" it seems
I imagine it would be more useful as a score calc app if you would take turns, like you do in bowling
so I would enter my frame one score, then you enter yours, I enter frame two, etc
ya exactly
thats what i thought would be best
okay, so we need to track a few more things and introduce some new variables
First, we should make a class that represents a single player and their entries
we can then store an array or a list of these in our program to make it easy to have multiple players
we also need to track what frame we are on
and some way of keeping track what players turn it is
Ive created a class, not sure how to do the rest.
what does your class look like?
namespace BowlingProgram
{
class Player
{
}
}
$codegif
and leave the namespace out :p
you'll need to add some data to that class
a name or number to identify the player and their frame values, for example
line an int?
or string or whatever
yeah, a property
public string Name
{
get { return _name; }
}
looks good?
is all you need
also, please use the backticks when pasting code in discord
3 backticks followed by the word "cs", like in the gif above
```cs
like that
there!
almost but not quite
okay, should i create one for a number as well or is that enough?
oh yeah yours has colours
ill watch the gif in the mean time
well if we have the name we dont need a number, since they can be "{name}" instead of "player {number}"
Okay, so what should the next step be
a list?
well you used a 2d array in your current code
I'm not personally a big fan of that, but it works
Can't do much else lol
this is kinda how I imagine it playing btw
this is the output from my console version of this app btw š
sure you can. You could for example create a struct that was two ints, and store an array of that.
its a bit more complicated thou, so we can keep using a 2d array
its not a problem
youve made a console bowling?
well, its just a score keeper just like yours
but yes
I made it now, while talking to you
that was also my vision without the label saying whos turn it is lol
in the 10 minutes it took me to create a string
lol
Don't compare yourself to others, especially not ones with 20+ years of experience š
So, did you create a score array for the player?
ĀÆ\_(ć)_/ĀÆ
Gonna go sleep. Good luck!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.