Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 10th, 2006, 2:23 AM   #11
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5 lectricpharaoh will become famous soon enough
I did one in C++ (Win32, using DevC++) several semesters ago for a C++ class, and later ported it to Java for a Java class. The C++ version is actually a console program (uses the so-called 'extended ASCII' block-drawing characters), while the Java one is graphical. In order to port the code, I had to change lots of little things to compensate for minor differences in syntax and language, and of course the drawing routines had to be totally rewritten. Still, it was an interesting exercise, and if you'd care to see the C++ source, I can put it on the net and post a link.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old May 11th, 2006, 4:47 PM   #12
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Quote:
Originally Posted by lectricpharaoh
I did one in C++ (Win32, using DevC++) several semesters ago for a C++ class, and later ported it to Java for a Java class. The C++ version is actually a console program (uses the so-called 'extended ASCII' block-drawing characters), while the Java one is graphical. In order to port the code, I had to change lots of little things to compensate for minor differences in syntax and language, and of course the drawing routines had to be totally rewritten. Still, it was an interesting exercise, and if you'd care to see the C++ source, I can put it on the net and post a link.
Yes please!
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old May 11th, 2006, 11:22 PM   #13
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Eric the Red
Yes please!
Okay, it should be up now, and you can grab it here. I have only put the source files in the archive, as the object/executables can be built, and the project file probably contains path information specific to my system, so you'll need to make a new project (deleting any files DevC++ creates by default, like main.cpp), and then add the files in the archive. You will also need to make sure that the right libraries are linked. The defaults should be fine, with one exception: In DevC++ (my version, anyways), go to 'Project', then 'Project Options', then click the 'Parameters' tab, and below the 'Linker' box, there will be a button labelled 'Add Library or Object'; click it. Browse to DevC++'s lib path, and add the file 'libwinmm.a'. If you're trying to build the code under Visual C++, I believe the filename is 'winmm.lib', but I make no guarantees if the code is compatible (VC++ is sometimes flaky).

Anyways, I don't care what you do with it, as long as you don't try to claim you wrote it. If you learn something from it, though, that's great. Also, the code might be a bit ugly (I wrote it like the night before my project was due, so it was kinda rushed, though I have tweaked it a bit since). You'll notice the drawing logic is somewhat separate from the block logic, so it should be possible to rewrite it as a graphical app without changing the core logic too much.

[edit] You'll probably want to change the size of the console window it launches in (the game assumes 80x50), or use alt-enter to go to full screen. Also, the keys are as follows: ESC to exit, SPACE to pause, ALT to rotate clockwise, CTRL to rotate counterclockwise, and the RIGHT, LEFT, and DOWN cursor keys to move blocks. If you want to change the keys, it should be quite trivial. [/edit]
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old May 11th, 2006, 11:59 PM   #14
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Quote:
Originally Posted by lectricpharaoh
(I wrote it like the night before my project was due, so it was kinda rushed, though I have tweaked it a bit since).
thanks!!!

1 question: Was this a university course? because i'm doing this for high school
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old May 12th, 2006, 12:11 AM   #15
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Eric the Red
thanks!!!

1 question: Was this a university course? because i'm doing this for high school
College, but it was a super easy course. I already knew everything that was taught in it (I'd already been using C and C++ for a bit), but I needed credit, so I kinda had to take it.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old May 18th, 2006, 12:33 AM   #16
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Alright so my tetris game is done. Now I want to add a little "bang" to the game. So I came up with a great idea. I just need your help in telling me if this is possible and can be done in Java. Here's how my idea plays out.

So you go to this website, which I created from cogeco and your able to play tetris through an applet. So far This can be done.

Now on the website I want to have a highscore list for "top ten highscores". Now depending on if your score is good enough, I want to be able to upload this score to my website.

Note: I'm really bad at this website stuff. But I know this much. I update my website through FTP using "FileZilla", where I can add a .html file to my folder online. However, is it possible for a java applet/ application to be able to connect to this website and update it?

I'm a complete noob at this website stuff, so any help would be greatly appreciated. Just put it this way, before today I didn't even know how upload to my website.
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote
Old May 18th, 2006, 3:34 AM   #17
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by Eric the Red
I just need your help in telling me if this is possible and can be done in Java.
Yes it's possible. Ask in the Java forum on how to connect to a website and update or upload a file.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old May 20th, 2006, 8:44 AM   #18
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Eric the Red
Note: I'm really bad at this website stuff. But I know this much. I update my website through FTP using "FileZilla", where I can add a .html file to my folder online. However, is it possible for a java applet/ application to be able to connect to this website and update it?

I'm a complete noob at this website stuff, so any help would be greatly appreciated. Just put it this way, before today I didn't even know how upload to my website.
Just a note: if you're using Windows, you generally don't need a third-party FTP client. In Win2000/XP, at least, using 'My Network Places' allows you to set up shortcuts. Of course, if you want to do more sophisticated operations than copying files to/from your webspace, a third-party client might be worthwhile.

That said, you have three options. If you've got web hosting as part of the package from your ISP (comes with many, if not all, broadband accounts), you will likely not have any server-side scripting ability. In this case, you will need to upload the data through the prescribed method, which is FTP for you (some allow HTTP PUT operations). If you want to do this from code, you will need to negotiate the connection, submit your username and password, read the contents of the file, modify it, and then send the new contents. This means your username/password will be available to anyone who decompiles your Java .class file(s) where this information is stored, or perhaps even any script kiddie with a hex editor. In other words, this is not a secure option, at least not if you want to distribute the code to anyone you trust.

The second option is only available if you have some kind of server-side scripting support on your site, which will most likely be the case for bona-fide web hosting, but not for most ISP bundled-with-account webspace. Using this technique, you can have the program submit the data in the same way a browser submits form data to the server: through the URL (the 'GET' method), or through the HTTP header (the 'POST' method). If your site supports ASP, ASP.NET, JSP, and/or CGI, you can use this method. Once you submit the data to your site, the server runs the appropriate script to process the data, and then sticks it in a file or updates a database that resides on the server (most web hosting that allows server-side scripting also provides some database functionality such as MySQL). The only potential problem with this method is that it is possible for an attacker to submit bogus data through the browser (if the data is passed in the URL) or by passing a bogus header (which can be done by various means, like TELNET). One way to discourage this might be to scramble the data in some way, and add additional data that would act as a verification, in a similar way to a checksum or hash. That way, the attacker could only re-submit the same result (and if the server-side script scanned for duplicate entries, it could reject it), but making up new results would be quite difficult.

The third possibility is a mix between the two. Find someone with 'real' web hosting, and have your program submit the results there. You could still link from your site, and the remote script could generate actual HTML output to add content to your site (a table of high scores, for example).
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:02 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC