|
Hello,
Firstly I'm very new to C# so I'll apologise in advance for what may sound like silly questions.
I'm want to write a small game application where things move on the screen. It is a turn based app and as soon as one persons turn is over the graphics update with the new position.
I understand the business logic side but as far as the visual side goes I'm not sure how graphics work in C# and would very much appreciate some pointers on where to start.
Do I draw the game board first and then overlay stuff on it? If so how? Or do I draw a game board every time a person moves?
Any help is greatly appreciated.
Thanks,
Monk
|
|
|
|
|
Monk111 wrote: I'm very new to C#
Monk111 wrote: I'm want to write a small game application where things move on the screen
These are probably mutually exclusive statements. You should learn core C# before learning extension libraries like GDI+
If the Graphics.Drawing namespace doesn't do what you want, then you need DirectX
Monk111 wrote: Do I draw the game board first and then overlay stuff on it?
Almost certainly
Monk111 wrote: If so how?
With bitmaps that havbe transparency masks, or 3D models.
Monk111 wrote: Or do I draw a game board every time a person moves?
Yes, you will have to.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sorry I probably gave the impression that my core C# is very poor. It isn't. What I was trying to get across was that I have nvever touched on any graphics in C# so all this is very new.
Any other pointers would be helpful.....
|
|
|
|
|
Fair enough.
Well, for something turn based, you'd probably just use GDI+, unless you expect to do animations and stuff. You'd create bitmaps with, say, magenta backgrounds, and draw them on top of your background image, using the ImageAttributes class to specify that magenta is transparent. To do this, you can't store them as jpg, because jpg is lossy.
If you were to go the DX route, you'd find that there are a lot of samples in the SDK. I wrote a simple game in C#, it's presented on this site in three parts, it should give you some ideas.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
the simplest implementation is having one method that paints everything; when you wire this
to the Paint event of your Form, Panel, whatever, it will paint the initial image, and
repaint it whenever required (e.g. when another window drawn on top of it gets closed),
and also when you call Invalidate() which requests a redraw (e.g. because the other party
in the game has made a move).
For an extremely simple case, have a look at my Sokoban article.
|
|
|
|
|
Hey fellow developers,
Need help with a datagrid column...
In design time i have created a datagrid with 2 columns one is a DataGridViewComboBoxColumn type column the other is just plain text.
I am inserting data into the comboboxcolumn's items collection during runtime but when it has finished inserting into the items collection and i go to click the drop down button it does nothing.
The items are coming from a datagrids header text row.
code below;
for (i = 0; i < dataGrid.ColumnCount; i++)
{
MCForm.FileColumn.Items.Add(dataGrid.Columns[i].HeaderText.ToString());
//FileColumn is the name of the column which is set as a combobox column
}
Any idea's...
I have run through in debug mode and in the runtime properties it shows that there is items in the control but it just wont reflect back when i click the combobox button to show the items in the list.
Any help asap would be fantastic
|
|
|
|
|
Hi,
I have 6 groupBoxes with similar content. In otherwords groupBoxUnit1, groupBoxUnit2 thru groupBoxUnit6.
The number of units (1 thru 6) is entered by the user and I only want the form to display that number of units groupBoxes. For example, if there are 5 Units - display groupBoxUnit1 thru groupBoxUnit5.
I can do this with a CASE statement and a lot of typing and will be surprised if there isn't an easier alternative.
Any suggestions.
TIA
Glen Harvy
|
|
|
|
|
Put references to the controls in an array:
GroupBox[] groupBoxes = new GroupBox[] { groupBoxUnit1, ... , groupBoxUnit6 };
Now you can access them by index, so that you can loop through them and show the ones you want.
---
single minded; short sighted; long gone;
|
|
|
|
|
I thought of this but can't get my mind around it.
Can you give me some psuedo code as a hint
Glen Harvy
|
|
|
|
|
Something like this:
int visibleCount = 4;
for (int i = 0; i < groupBoxes.Length; i++) {
groupBoxes[i].Visible = (i < visibleCount);
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks for the help - much appreciated.
Glen Harvy
|
|
|
|
|
I have a form that runs a ftp call on load (or suitable event), however when the form loads it completely freezes will the ftp call is running. Is there a straight forward way of making the form still usable while the ftp call is running? Am I looking at a asynchrous call or something like that? I sort of got what I wanted by using threading but for some reason i couldn't close the form even when the method was done executing (seems like the thread was still running (how do you stop it?)
Cheers
|
|
|
|
|
Hi,
IMO you should do networking stuff in a separate thread, so have your Load event create
and start a thread. Be careful with the GUI tho, only the main thread is supposed to
(or allowed to) access GUI components, see the InvokeRequired and Invoke/BeginInvoke
property and methods.
You can find a simple example of a thread and the Invoke stuff in my Sokoban article;
there are alternative kinds of threads (with ThreadPool, BackgroundWorker, etc).
|
|
|
|
|
hi,i have created the editor in RichTextBox control
and implemented the goto line number functionality.
now I want to find the content length of the perticular line.
Thanks
|
|
|
|
|
Measure the text between the two return characters in the string.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi,
actually not clear can u elabarate it.
I think u got my problem
when ever u compile a program if it leads to any error if we double click that error that it will lead to an corresponding line where that error has been occured.
At present I am able to point to the error line but not the entire line is highlighted.
Thank you.
With Regards
Prasad
|
|
|
|
|
If you walk the characters going back from the position you're at, you will find a return character, or 0. If you go forwards, you will find a return character, or the end. This will tell you the length of the substring to highlight. The return has an integer value of (decimal)13. Environment.NewLine is two characters, 10 and 13.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi,
sorry i am not getting can u give one code example pls
help me pls
Thank u
|
|
|
|
|
a string contains chars.
foreach (char c in "abcdefg")
will iterate over each charater. You can do it by index, too.
string s = "spit";
s[1] = 'h';
for example.
So, you can take the location of hte cursor, and then look back and forwards for the return character.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you
it is working
With Regards
prasad
|
|
|
|
|
I have a popup displayed with a form by function:
taskbarNotifier1.Show("HostName: \n\n SiteHit: \n\n Survey: \n\n TAF: \n\n ATO: ", strQuery, 300, 2000, 300);
Now these hostname,survey,taf,ato i have to get from database :
select url,sitehit,survey,tellafriend,addtooutlook from tblsummary where...
of current datetime ie the last current entry of database and display all these data in 'strQuery' in above function in a line ie one after other like this :
Hostname : nekshan@yahoo.com
Sitehit : 1
Survey : 0
These in bold are data to be displayed by the query.
how to get all this data in one variable to put it in my function n display data in this format.
Hope u r getting my Point.
Thanx
nekshan.
|
|
|
|
|
Create a struct to hold all this data, if you want to pass it all in one go.
Or, if it has to be a string, use a delimiter or build a query string, like a URL.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
function can only return one value
so if u want all three then u have to concat all in one variable like
str = str1 + '#' + str2 + '#' + str3
then return str from function
now on form u have to seperate all three from str by using mid(str,'#',1) like this not exactly this function is. u have to seperate like this all in different variable then use it.
bye. virendra.
|
|
|
|
|
Yeah, that's one of the answers I gave. Why did you give it 4 times ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
function can only return one value
so if u want all three then u have to concat all in one variable like
str = str1 + "#" + str2 + "#" + str3
then return str from function
now on form u have to seperate all three from str by using mid(str,'#',1) like this not exactly this function is. u have to seperate like this all in different variable then use it.
bye. virendra.
|
|
|
|