In formating strings, how would I only get the decimals?
So, 1.456 would be .456(no digit before the decimal). I have seen a lot on removing the decimals or rounding to a certain place, but I'm curious as to how to do this or if it is even possible.
User Profile
Collapse
-
String Format removing leading digits
-
Rotating a 3D Point by a given degree angle in 3D Space
Given a point at some location, and an angle with witch to rotate the point by, how would this be done mathematically?
So, for example, my point is at 4,8,10 and I want to rotate it 28 degrees clockwise, how would this be done?
Any ideas and info is appreciated.
Thanks,
CodeNoob117 -
Rotating Viewing Platform JAVA 3D
I am wanting to rotate the viewing platform left and right, which should only be the x-z plane. How would I go about doing this? Any information and ideas is appreciated.
Thanks
CodeNoob117 -
JAVA 3D KeyBehavior or KeyListener
Would it be recommended to use KeyBehavior or is using a KeyListener still ok in the ethics of JAVA 3D programming?
CodeNoob117 -
Moving a point/object in a 3D Plane/Environment
The scenario:
An object rotated 30 degrees right and 10 degrees up wants to move forward on its x,y,z plane, which is offset from the standard plane because of its rotation.
Given a 3D Environment which has a standard x, y, z plane, and a separate object whose degree of rotation from the standard plane is known along with its x, y, z coordinates, how would the two x,y,z planes be correlated for movement? I want to think... -
Java(Android): Rotating an Image on Canvas
How would I rotate an image, in place, on canvas? I have an image at location (x, y) facing North (represented by: static double NORTH = 0.0) and want to turn the image to face the new location when a motion press occurs at (x2, y2). Given the starting direction, x and y coordinates, how could I achieve this? I have seen algorithms using Math.atan(); however, I have been unsuccessful in implementing these. Any advice and ideas is appreciated!... -
Drawing on Canvas in Android
I'm trying to draw a rectangle on a canvas in my own View:
...Code:public class CustomMainMenuDrawView extends View { Paint paint = new Paint(); public CustomMainMenuDrawView(Context context) { super(context); paint.setColor(Color.BLACK); } @Override public void onDraw(Canvas canvas) { paint.setColor(color.black); -
threading in classes instead of main
I want to make a thread outside an int main() method; and this code below gives an error of (paraphrasing) 'no constructor found for thread for type void()'
...Code:#include <thread>; class Board(){ //Lines Later void getPlayerInput(){//Code NotShown} void playGame(){ std::thread t1(getPlayerInput);//thread to get userInput } -
How to Thread in a Class file Outside int main() C++?
I want to make a thread for a player's input, which I have created a method for, while a computer moves at the same time. I know that there is std::thread in the C++ library, and boost::thread but I am not sure on how to proceed. Any suggestions?
Currently, this is what I have come up with:
...Code:#include <thread>; class Board(){ //Lines Later void getPlayerInput(){//Code Not Shown}Last edited by CodeNoob117; Nov 1 '13, 06:13 PM. Reason: Provide more clarity of question and issue. -
Thanks for the ideas! Though, when I did further debugging, I discovered the real problem; the issue wasn't creating new Missile objects- it was in the beginning of the fire() method:
Originally, I had used a linked list of pointers to point...Code:Missile *missile = new Missile(xPos, yPos, true);//Something went wrong here (*missile).setShotXPos(xPos); missiles.add(missile); //here missile = nullptr; //and here
-
Making new Class Instance and adding to linked list
I have a .cpp file which contains 5 smaller defined classes. In my missile class I have a default constructor and a constructor that I invoke
...Code:class Missile{ private: bool isHuman; int xPos = 0; int yPos = 0; public: Missile(){ } Missile(int x, int y, bool isPlayer){ xPos = x; yPos = y; isHuman = isPlayer; -
Can you tell me why I need a default constructor?
No, I did not have a default constructor for the Missile class, which apparently is needed, but could you explain why? I have a defined constructor for (int, int, bool) and I invoke that when using my pointer variable; so why does adding it to the list invoke the default? Thanks....Leave a comment:
-
Error C2512 with Template Linked List
I have made a Template Class that I named ArrayList(to coincide with ArrayLists in Java)and it works for the primitive types string, int, double, etc.; however, when I try making the ArrayList with a class object instead of a primitive type it gives:"error C2512: 'ArrayList<Miss ile>::listCell' : no appropriate default constructor available" and I am not sure why.
My ArrayList Class is defined by:
...Code:template
-
Thank you. Though my problem persists. I will provide some code for you; if you're willing to continue to help me.
...Code:public class Audio { public static void main(String args[]) throws IOException, UnsupportedAudioFileException, LineUnavailableException{ Clip clip = AudioSystem.getClip(); // getAudioInputStream() also accepts a File or InputStream AudioInputStream ais = AudioSystem.getAudioInputStream((newLeave a comment:
-
More Information Please?
Thanks, you helped me a lot, however I am getting this error at the moment: Exception in thread "main" javax.sound.sam pled.Unsupporte dAudioFileExcep tion: could not get audio input stream from input file
I looked through the link you provided(Thank you for doing so) but I did not manage to see any specified files the Clip and Audio classes read. What audio files are allowed...Leave a comment:
-
I found a way to mimic a credit scroll by using a class to extend JComponent. I used a file reader to put the lines of text in the file into a string array and then overrides the paint component to paint the text in the array. I used a parallel array of integers to track the x and y positions of the text and stopped drawing the text after its y was lower than a certain number. And had the component repaint itself after a timer counted down.Leave a comment:
-
Java: How to add Sound to Application
I want to add some background music to a credit line and other parts of the application, but I do not know how to go about such. I tried importing the sun.audio.*; and use the AudioPlayer, AudioStream, etc. however, there is a restriction to the access. Is there any way around this or any other method to add music/sound to the application?
Any help would be appreciated, thanks in advance.
-CodeNoob -
Java Programming: Making Credits
I want to make a scrolling credits screen that can be found at the end of most Games campaigns, or movies. How would I go about doing this in Java? Im thinking it would be some sort of rectangular text box that is redrawn several times to make a vertical scrolling movement, but I'm not sure how to proceed. Any ideas and advice on doing this is welcome. -
How to override ImageIcon paint method to display gif Image?
I am making a game in which it has a JFrame that contains a gridlayout full of Jlabels. I want to make a separate image class that can be added to the JLabels. So far, I have been trying to override the paintIcon method to draw a picture icon to the label. I have been trying, unsuccessfully, to draw an animated GIF. The code is as follows:
...Code:public class Infantry extends UnitIF{ ImageIcon icon; public void paintIcon(Component
No activity results to display
Show More
Leave a comment: