techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old Sep 5, 2011, 02:16 PM   #26
streetfighter 2
1000 Posts
 
streetfighter 2's Avatar
 
Join Date: Jul 2010
Location: Philly
Posts: 1,599 (1.55/day)
Thanks: 1,004
Thanked 765 Times in 539 Posts

System Specs

That isn't how you declare a while loop.

That's a for loop declaration.

It should be:
Code:
for (int i = 0; i < 25; i++){
It's a very common mistake, don't feel bad about it.

Last edited by streetfighter 2; Sep 5, 2011 at 02:27 PM.
streetfighter 2 is offline  
Reply With Quote
The Following User Says Thank You to streetfighter 2 For This Useful Post:
Old Sep 5, 2011, 02:25 PM   #27
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

I feel like crying in the corner now.

Edit: but a stupid one none the less. Seeing as I've used it correctly several times before.
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron
razaron is offline  
Reply With Quote
Old Sep 5, 2011, 02:58 PM   #28
caleb
1000 Posts
 
Join Date: Sep 2004
Location: Poland,Slask
Posts: 1,109 (0.35/day)
Thanks: 200
Thanked 174 Times in 142 Posts

System Specs

Maybe use FOR instead of WHILE
__________________
"Let me noobilize you"
caleb is offline  
Reply With Quote
The Following User Says Thank You to caleb For This Useful Post:
Old Sep 5, 2011, 03:31 PM   #29
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

Quote:
Originally Posted by razaron View Post
What would be a logical step up from the archery game? Preferably something that doesn't require much imagination (so no text adventure).
Good job on the game

The next logical step would be to make the game more complex.
For instance, instead of just having the target be X distance away, give it a left and right position so that the player has to enter the angle to turn also (Power=10, Angle=25, 30° to the left).
If the player misses, have the target advance and moves left or right toward him some random amount before the next shot. If the target reaches the player, the player "dies".
See if the player gets the target or the target gets the player (call it a zombie instead of a "target" )

Then ... add multiple zombies attacking.

Also, I saw your comment about methods returning void (or nothing).
This means it returns no value to whatever called it. You will also get an error if you try to get a return value from a void method.
Code:
void MyMethod()
{
    // Do something, but return nothing.
}

int test = MyMethod() <-- Error
However, if a method returns a value, you do not have to use it if you do not need what it returns.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp

Last edited by Kreij; Sep 5, 2011 at 03:40 PM.
Kreij is online now  
Reply With Quote
The Following User Says Thank You to Kreij For This Useful Post:
Old Sep 5, 2011, 03:43 PM   #30
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

So a void method is like a bully?
"What's yours is mine and what's mine is also mine.", said the void method to the other methods.
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron
razaron is offline  
Reply With Quote
Old Sep 5, 2011, 03:50 PM   #31
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

Another thing to keep in mind, as I stated above, is that when you look at code just because a method call does not use it's return value, does not mean it does not return anything.

For instance, the Show method of the MessageBox class in C# returns a value of type DialogResult. If you don't care what that value is, you can call the method and just let it pitch the result or use it if you need it.
Code:
MessageBox.Show("Text for messgae box"); // Don't need result

or

DialogResult MyResult = MessageBox.Show("Text for message box"); // Save result for later
A void method isn't a bully, it's just so broke it can't afford to give anything back


Also, Java is not dead. It's used by a lot of people for it's cross-platform capabilities.
for instance, Minecraft is written in Java.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp

Last edited by Kreij; Sep 5, 2011 at 03:58 PM.
Kreij is online now  
Reply With Quote
Old Sep 5, 2011, 04:09 PM   #32
human_error
1000 Posts
 
human_error's Avatar
 
Join Date: Nov 2008
Location: Southampton, UK
Posts: 1,443 (0.87/day)
Thanks: 261
Thanked 421 Times in 322 Posts

System Specs

Quote:
Originally Posted by Aleksander Dishnica View Post
Java is dead, start c++
That's why a large number of corporations have programs written in Java (some of these programs make billions each year in revenue)? Java is hardly dead, and it isn't going to be going away for a looong time.

As for what to develop next Kreij is right - it is much better to improve on and add to an existing program if you want to try more complex things, at least until you can't think of any more ways to add to it.
__________________
Steam id: human_error/XBOX Live: human error/PS3 id: tom_will
Human_error's guide to USB IR receivers and media center remotes
My BF3 stats | BF3 name: "human_error" - add me!

Last edited by human_error; Sep 5, 2011 at 04:14 PM.
human_error is offline  
Reply With Quote
Old Sep 5, 2011, 04:16 PM   #33
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

Currently I'm going through the different kind of data structures (array, bitset etc.). After that I'm going to learn basic swing and remake "Fate/stay night" with place-holders for all the audio, text and images. That ought to help in getting used to the syntax.
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron
razaron is offline  
Reply With Quote
Old Sep 5, 2011, 04:29 PM   #34
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

When learning the different data structures, take the time to learn not only how they work but where they are a "best fit".

If you need a data structure to hold a bunch of strings you could use an array, but depending upon what you are doing (like maybe adding and remove them) a List of string may be more appropriate because it will execute faster and is inherently dynamic in size.

Quote:
Originally Posted by Human Error
As for what to develop next Kreij is right - it is much better to improve on and add to an existing program if you want to try more complex things, at least until you can't think of any more ways to add to it.
You mean after writing your first "Hello World" program you should not jump right into making a 3D shooter?
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
The Following User Says Thank You to Kreij For This Useful Post:
Old Sep 5, 2011, 04:52 PM   #35
streetfighter 2
1000 Posts
 
streetfighter 2's Avatar
 
Join Date: Jul 2010
Location: Philly
Posts: 1,599 (1.55/day)
Thanks: 1,004
Thanked 765 Times in 539 Posts

System Specs

Quote:
Originally Posted by Aleksander Dishnica View Post
Java is dead, start c++
No offense good sir, but I've seen your posts: you do not know that much about programming.
Quote:
Originally Posted by razaron View Post
So a void method is like a bully?
"What's yours is mine and what's mine is also mine.", said the void method to the other methods.
It should be noted that void methods can still modify variables, whether globals, class members or certain types of passed objects (similar to python). This gets confusing so check this out:
http://www.javaworld.com/javaworld/j...0526-pass.html

Java doesn't support void type variables (AFAIK) but other languages do. For instance I wanted a function to retrieve private variables from a class instance in C++. The traditional way to do this is with a template, which is a type of generic specific to C++. (Java [J2SE 5.0+] also supports generics.) I intend to create a generic but for now I'm prototyping the behavior using void:
Spoiler

What that function does is allow you to pass in a variable of several different types, then request a variable by name and retrieve the desired value from the object instance. It would be invoked like this:
PHP Code:
TCHAR szDir[MAX_PATH];
tProfileControl->request(szDir,_T("szDir")); 
It also uses loads of pointers which Java doesn't support . . .

NOTE: I'm using php tags for syntax highlighting, the code is written in C++.
Quote:
Originally Posted by Kreij View Post
When learning the different data structures, take the time to learn not only how they work but where they are a "best fit".
Not only that, but if razaron learns how to build his own data structures he can fit data structures to code rather than fit code to data structures. I'm pretty sure that sounds more confusing than I want it to be.

Last edited by streetfighter 2; Sep 5, 2011 at 05:25 PM.
streetfighter 2 is offline  
Reply With Quote
Old Sep 5, 2011, 05:46 PM   #36
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

Quote:
Originally Posted by streetfighter 2 View Post
Not only that, but if razaron learns how to build his own data structures he can fit data structures to code rather than fit code to data structures. I'm pretty sure that sounds more confusing than I want it to be.
We may want to give raz a little time to let the basics sink in before we give him an aneurysm trying to figure out delegates, generics, llambda expressions, etc.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
The Following User Says Thank You to Kreij For This Useful Post:
Old Sep 5, 2011, 06:24 PM   #37
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

Keep it on topic. He asked for help with Java, not for personal opinions on the merits of any particular programming language. Posts removed.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
The Following 2 Users Say Thank You to Kreij For This Useful Post:
Old Sep 5, 2011, 10:02 PM   #38
Aleksander
2000 Posts
 
Aleksander's Avatar
 
Join Date: Dec 2009
Posts: 3,028 (2.39/day)
Thanks: 648
Thanked 280 Times in 228 Posts

System Specs

Ok, sorry for the other post, but anyway i don't know why none suggested any videos
http://www.youtube.com/watch?v=Hl-zzrqQoSE
Thenewboston is well known for teaching
If i was you i would learn all the videos than come here again after learning that much
@streetfighter 2
I have not seen a program like the one in my signature.... yet

Last edited by Aleksander; Sep 5, 2011 at 10:11 PM.
Aleksander is offline  
Reply With Quote
The Following User Says Thank You to Aleksander For This Useful Post:
Old Sep 25, 2011, 02:08 PM   #39
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

[figured it out]
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron

Last edited by razaron; Sep 25, 2011 at 02:29 PM.
razaron is offline  
Reply With Quote
Old Sep 25, 2011, 06:53 PM   #40
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

This results in a stackoverflow error.
If I remove " && halffact1==0.75 && halffact2==0.75 && halffact3==0.75" from the "checkGrid()" method then it results in an array full of zeros.
What am I doing wrong?
Spoiler
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron
razaron is offline  
Reply With Quote
Old Sep 25, 2011, 07:01 PM   #41
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

I'm not sure but it looks like the checkGrid method is returning itself (which would cause a stack overflow because you are not specifying that it return the local boolean variable by the same name (this.checkGrid).
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
Old Sep 25, 2011, 07:14 PM   #42
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

To call a method in Java you must have "()" at the end of the name even if there are no parameters.
Today is not your day, lol.

EDIT: The method checkGrid() returns a boolean named checkGrid, the method primaryGrid() returns an array named primaryGrid and the method secondaryGrid() returns an array called secondaryGrid. I realize this is confusing. That's just how I like it...
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron

Last edited by razaron; Sep 25, 2011 at 08:04 PM.
razaron is offline  
Reply With Quote
Old Sep 26, 2011, 02:48 AM   #43
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

You are right. Today has not been my best day. lol
Oh well, it's not the first time.

I know you need to include the parenthesis when calling a method, but I was thinking that when you return checkGrid (without the parenthesis) it may be returning a pointer to the method instead of the value of the local checkGrid variable.

I probably just need some sleep so I can once again seperate different programming language syntax in real time.

Code:
private static protected const internal void **string MyMethod (string *$lolwut)
{
   10 : return ***this.MyMethod->&MyMethod (&(LPTRSTR)(@"Just kill me now"));
   goto: 10;
}
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp

Last edited by Kreij; Sep 26, 2011 at 02:59 AM.
Kreij is online now  
Reply With Quote
Old Sep 26, 2011, 02:08 PM   #44
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

I took the recursion out of the secondaryGrid() method and moved the double casts (in the checkGrid() method) into the brackets. It now works perfectly.
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron
razaron is offline  
Reply With Quote
Old Oct 12, 2011, 09:45 AM   #45
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

I have a really weird problem.
This works,
PHP Code:
long time getTime();
double theta = (360*time)/1000;
long x = (long)(100 Math.cos(Math.toRadians(theta)));
long y = (long)(100 Math.sin(Math.toRadians(theta))); 
but this doesn't,
PHP Code:
long time getTime()%1000;
double theta 360*((time)/1000);
long x = (long)(100 Math.cos(Math.toRadians(theta)));
long y = (long)(100 Math.sin(Math.toRadians(theta))); 
This code is supposed to give the x,y co-ords of a dot thus animating it. getTime() returns a long value of time in milliseconds.
The second piece of code is mathematically sound but doesn't work.
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron

Last edited by razaron; Oct 12, 2011 at 09:54 AM.
razaron is offline  
Reply With Quote
Old Oct 12, 2011, 07:05 PM   #46
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

Define "doesn't work".
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
Old Oct 12, 2011, 07:12 PM   #47
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

One animates. The other just has a static image.
I fiddled a bit more and figured out something even more weird. If for the second piece of code I make theta equal (360*time)/1000, it animates.
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron
razaron is offline  
Reply With Quote
Old Oct 12, 2011, 11:55 PM   #48
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,126 (5.27/day)
Thanks: 591
Thanked 5,494 Times in 2,938 Posts

System Specs

The two code blocks you posted are not mathematically equivelant.
I guess still an not sure how to respond.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is online now  
Reply With Quote
Old Oct 13, 2011, 12:03 PM   #49
razaron
500 Posts
 
razaron's Avatar
 
Join Date: Apr 2008
Location: london
Posts: 608 (0.33/day)
Thanks: 170
Thanked 185 Times in 140 Posts

System Specs

The cosine and sine make them mathematically equivalent. The theta values are different but the cos(theta) and sin(theta) values are the same. Check it on a calculator.
Also, 360 * (time/1000) == (360*time)/1000. Think of them as fractions.
__________________
My Anime List
BattleTag (EU): razaron#1882
Steam: Razaron

Last edited by razaron; Oct 13, 2011 at 01:28 PM.
razaron is offline  
Reply With Quote
Old Oct 13, 2011, 01:23 PM   #50
Aleksander
2000 Posts
 
Aleksander's Avatar
 
Join Date: Dec 2009
Posts: 3,028 (2.39/day)
Thanks: 648
Thanked 280 Times in 228 Posts

System Specs

I think it is not a mathematical problem here.
It is java which takes the time as another thing and an int as another.
Probably you cannot divide time.
Not that i know java though.

Also, this 360 * (time/1000) == (360*time)/360 is not equal
Aleksander is offline  
Reply With Quote
Reply


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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Very noobi question in Java Flash Programming & Webmastering 7 Apr 20, 2011 06:31 PM
C# question (java related) spy2520 Programming & Webmastering 33 Feb 28, 2010 12:32 PM
My First Programming Question (Java) spy2520 Programming & Webmastering 13 Oct 29, 2009 03:17 AM
Java partially filled arrays question wolf2009 Programming & Webmastering 1 Apr 14, 2009 01:09 AM
Java Question dcf-joe Programming & Webmastering 1 Dec 24, 2008 01:12 PM


All times are GMT. The time now is 10:44 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts