C
C#ā€¢2y ago
nawt in use ;(

ā” Implement local players using a single button in Windows Forms bowling game

Csharp!!!
36 Replies
Pobiega
Pobiegaā€¢2y ago
okay, so, how do you currently track the players score/stats/whatever?
nawt in use ;(
nawt in use ;(OPā€¢2y ago
I havent created the most sophistiaced way to do that, i just write it in and dont mess with it
Pobiega
Pobiegaā€¢2y ago
$code
MODiX
MODiXā€¢2y ago
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/
nawt in use ;(
nawt in use ;(OPā€¢2y ago
should i post my whole thing?
Pobiega
Pobiegaā€¢2y ago
sure
nawt in use ;(
nawt in use ;(OPā€¢2y ago
BlazeBin - tmnoirhpfumg
A tool for sharing your source code with the world!
nawt in use ;(
nawt in use ;(OPā€¢2y ago
How the UI looks like currently
Pobiega
Pobiegaā€¢2y ago
Ah okay, so its a bowling score calculation app more or less
nawt in use ;(
nawt in use ;(OPā€¢2y ago
Basically
Pobiega
Pobiegaā€¢2y ago
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
nawt in use ;(
nawt in use ;(OPā€¢2y ago
ya exactly thats what i thought would be best
Pobiega
Pobiegaā€¢2y ago
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
nawt in use ;(
nawt in use ;(OPā€¢2y ago
Ive created a class, not sure how to do the rest.
Pobiega
Pobiegaā€¢2y ago
what does your class look like?
nawt in use ;(
nawt in use ;(OPā€¢2y ago
namespace BowlingProgram { class Player { } }
Pobiega
Pobiegaā€¢2y ago
$codegif
Pobiega
Pobiegaā€¢2y ago
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
nawt in use ;(
nawt in use ;(OPā€¢2y ago
line an int? or string or whatever
Pobiega
Pobiegaā€¢2y ago
yeah, a property
nawt in use ;(
nawt in use ;(OPā€¢2y ago
public string Name { get { return _name; } } looks good?
Pobiega
Pobiegaā€¢2y ago
public string Name { get; }
public string Name { get; }
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
nawt in use ;(
nawt in use ;(OPā€¢2y ago
public string Name { get; }
public string Name { get; }
there!
Pobiega
Pobiegaā€¢2y ago
almost but not quite
nawt in use ;(
nawt in use ;(OPā€¢2y ago
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
Pobiega
Pobiegaā€¢2y ago
well if we have the name we dont need a number, since they can be "{name}" instead of "player {number}"
nawt in use ;(
nawt in use ;(OPā€¢2y ago
public string Name { get; }
public string Name { get; }
Okay, so what should the next step be a list?
Pobiega
Pobiegaā€¢2y ago
well you used a 2d array in your current code I'm not personally a big fan of that, but it works
nawt in use ;(
nawt in use ;(OPā€¢2y ago
Can't do much else lol
Pobiega
Pobiegaā€¢2y ago
this is kinda how I imagine it playing btw
Now playing frame number 1
Pobiega's turn.
First shot: 10
Strike!
Nyaa's turn.
First shot: 7
Second shot: 3
Spare!
Now playing frame number 2
Pobiega's turn.
First shot:
Now playing frame number 1
Pobiega's turn.
First shot: 10
Strike!
Nyaa's turn.
First shot: 7
Second shot: 3
Spare!
Now playing frame number 2
Pobiega's turn.
First shot:
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
nawt in use ;(
nawt in use ;(OPā€¢2y ago
youve made a console bowling?
Pobiega
Pobiegaā€¢2y ago
well, its just a score keeper just like yours but yes I made it now, while talking to you
nawt in use ;(
nawt in use ;(OPā€¢2y ago
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
Pobiega
Pobiegaā€¢2y ago
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!
Accord
Accordā€¢2y ago
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.
Want results from more Discord servers?
Add your server