Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Making A Game Save...


  • Please log in to reply
14 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:09:35 PM

Posted 05 September 2008 - 10:17 AM

I am making my own mini rpg (Role Playing Game) Called Flump Island (Dont Ask Where the name came from) and i have just learnt how to produce a random number so that will be usefull, i also need to know how to use hotkeys for future games ie when W is pressed the imageBox'es Y axis is increased by 4? i dont have a clue how that works so that would be great if you could help me on that and now to the main topic, I have created the start of the game but befour i go any ferther i would like to know i can make myself abel to save the level, expirence and weapon etc. i have guessed i would be abel to use note pad for this by saving a notepad with .txt extention and it will contain the name and then in a seperate one there lvl etc so it would be something like this...

private void SaveButton_Click(object sender, EventArgs e)
{
"C:\\Program Files\\FlumpIsland\\Level.exe".Text = textBox1.Text
}

So how Far am i away from the awnser or is this impossible, or is there a better way. Bere in mind ive only been learning for about three weeks and ive bee teaching myself, only because i have to wait till im 16 to do a collage corce :thumbsup:

BC AdBot (Login to Remove)

 


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer


  • Malware Response Team
  • 12,304 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:02:35 PM

Posted 05 September 2008 - 01:44 PM

Before someone can help... we need to know what language you are writing this in.

Billy3
Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

#3 Romeo29

Romeo29

    Learning To Bleep


  • BC Advisor
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:04:35 PM

Posted 05 September 2008 - 04:36 PM

Do you understand and know how to use DirectX using C#?

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:35 PM

Posted 05 September 2008 - 04:46 PM

DirectX


I'm tying really hard to figure out what DirectX has to do with saving a text file using C#?

@Wolfy87, what online resources have you found to help you with your code? It looks to me like you are just throwing code together without really understanding anything, and that just isn't going to work. You are tying to run before you can walk, ie, you are not taking the time to understand the basic structures, or how to find the code that you need online. A simple google search along the lines of "saving text file c#" ought to give you plenty of examples. It is apparent from your code that you do not even understand the basics. "C:\\Program Files\\FlumpIsland\\Level.exe".Text = textBox1.Text is not even proper syntax, in any language. In a statement like that, the value on the right sid of the equal sign is assigned to the value on the left side of the equal sign. You have it exactly backwards. So you are not even close.

#5 Romeo29

Romeo29

    Learning To Bleep


  • BC Advisor
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:04:35 PM

Posted 05 September 2008 - 06:29 PM

I'm tying really hard to figure out what DirectX has to do with saving a text file using C#?


The questioner is trying to make a computer game in C# and asking how to save a text file in C#. If you use a little reasoning... you can direct the questioner in the right direction.

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:35 PM

Posted 05 September 2008 - 07:42 PM

If you use a little reasoning... you can direct the questioner in the right direction.

Right. The code in c# to save a text file is three lines, and has nothing to do with DirectX, so how does directing the questioner in what seems to me to be an irrelevant direction help?

#7 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:09:35 PM

Posted 06 September 2008 - 05:42 AM

1. Im writing in C# which is clearly stated in the name...sort of...
2. I am extreamly new to programming so no, i dont realy understand most of what i wright but i do know basic code just not the backgroud of it i.e what proc means when i am making a button open an internet browser in the specified url location, but i know how to do it.
I only posted my idea of the code as a compleat guess because I could not find and help on this matter that i understood on google or C Sharp Corner.
And why would i need to know how to use DirectX, i thought that was a game Graphics Driver or Game Driver?

Edited by Wolfy87, 06 September 2008 - 05:44 AM.


#8 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:09:35 PM

Posted 06 September 2008 - 05:48 AM

Ok, Thank you Groovicus for the search criteria, it has helped me find what looks like an awnswer which i could not find befour hand with the search i was using, i think i was using too many key words.

#9 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:09:35 PM

Posted 06 September 2008 - 07:18 AM

This is my Resorce And this is where i lernt how to write to a .txt file and i can get this to work no problem, but when it comes to the Reading i dont realy understand what its meant to do? can i use this process to Wright the saved text to another thextBox? if so how?
I use this code to Write it...

private void button7_Click(object sender, EventArgs e)
{
TextWriter tw = new StreamWriter("RndNum.txt");
tw.WriteLine(textBox1.Text);
tw.Close();
}

But how do i repost it into textBox2 via button10_Click?

Edited by Wolfy87, 06 September 2008 - 07:23 AM.


#10 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:35 PM

Posted 06 September 2008 - 07:43 AM

The code you have there will only write the text to a file, it will not write it anywhere else.

Search terms:
Read text from file c#
textbox append c#

Those should get you started. You should really get familiar with the documentation, which is available on the Microsoft Developer Network. You are asking questions that are far beyond simple syntax. You are asking questions that deal with programming techniques, which take a very long time to explain. You are asking "how do I do this", not "how do I write this?" The second question is usually pretty easy to answer because it is just a matter of using the proper syntax of a given language. The first question is much harder because it deals with programming concepts. It's a bit like trying to teach you Calculus before you have even had algebra. If you would have reviewed the documentation for StreamWriter, you would see what it can and can not do, and you would know that it is not used to write to a text field, and you would not have to ask. All you are doing at his point is throwing code together and hope something sticks, and that will never work. I understand that you are tying to make a game, how about trying to tack random dice rolls or something? Manipulating files is a somewhat advanced topic, especially when you do not yet even understand how to assign values to variables.

#11 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:09:35 PM

Posted 06 September 2008 - 12:17 PM

Got it thanks :flowers: im making my game now whilst doing home work lol i got to stop programming for a bit or my work will be terrible, but its not too important, its not corcework or anything so it dosent matter too much. Once again thanks Groovicus :thumbsup:

#12 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:35 PM

Posted 06 September 2008 - 12:22 PM

Speaking of homework, I should be doing mine also...

#13 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:09:35 PM

Posted 06 September 2008 - 12:42 PM

Ok, good luck with it :thumbsup: dont you just hate it :flowers:

#14 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:35 PM

Posted 06 September 2008 - 01:06 PM

dont you just hate it

While it is true that it keeps me from doing other things that may be more fun, I do not hate it. I learn a lot from doing homework, and the more time I spend on my homework, the beter prepared I am for class. The better I am prepared for my class, the better my grades. ;)

#15 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:09:35 PM

Posted 07 September 2008 - 10:33 AM

Good point :thumbsup: but for some reason im really not motivated in school, im in year 10...proboly my most important year but i just despise it so much :/ but im in sort of councilling for it and taking a herbal remidy called st jhons wort that boosts the seretonin levels in the brain which is meant to help lol. ive got to do it but that dosent mean i want to :flowers:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users