Jump to content

Explv's Dank Paint Tutorial


Recommended Posts

Posted

How do I use the string in onPaint?

right now I have

g.drawString("Elapsed Time: "  + startTime, 20, 265);                but it isn't working so well lol

Add this method:

public final String formatTime(final long ms){
    long s = ms / 1000, m = s / 60, h = m / 60;
    s %= 60; m %= 60; h %= 24;
    return String.format("%02d:%02d:%02d", h, m, s);
}

Taken from the OP.

 

now in place of startTime, put

formatTime(startTime)

And it should work well.

Posted

Add this method:

public final String formatTime(final long ms){
    long s = ms / 1000, m = s / 60, h = m / 60;
    s %= 60; m %= 60; h %= 24;
    return String.format("%02d:%02d:%02d", h, m, s);
}

Taken from the OP.

 

now in place of startTime, put

formatTime(startTime)

And it should work well.

At the login screen it says; Elapsed Time - 00:00:00 and when it actually starts ingame it just says 12:25:06 and stays like that.

 

 

So I've added

private long startTime;

 
final long runTime = System.currentTimeMillis() - startTime;
 
public final String formatTime(final long ms){
   long s = ms / 1000, m = s / 60, h = m / 60;
   s %= 60; m %= 60; h %= 24;
   return String.format("%02d:%02d:%02d", h, m, s);}
 
 
then to onStart I've added
 
startTime = System.currentTimeMillis();
 
and onPaint:
 
g.drawString("Elapsed Time: "  + formatTime(startTime), 10, 332);
Posted

 

At the login screen it says; Elapsed Time - 00:00:00 and when it actually starts ingame it just says 12:25:06 and stays like that.

 

 

So I've added

private long startTime;

 
final long runTime = System.currentTimeMillis() - startTime;
 
public final String formatTime(final long ms){
   long s = ms / 1000, m = s / 60, h = m / 60;
   s %= 60; m %= 60; h %= 24;
   return String.format("%02d:%02d:%02d", h, m, s);}
 
 
then to onStart I've added
 
startTime = System.currentTimeMillis();
 
and onPaint:
 
g.drawString("Elapsed Time: "  + formatTime(startTime), 10, 332);

 

Oh should have been

formatTime(runTime)

Sorry was my bad or something.

  • Like 1
Posted (edited)

Oh should have been

formatTime(runTime)

Sorry was my bad or something.

Now it just says 12:45:43 from login screen and aswell when it runs unsure.png

 

EDIT: It works now.

 

Changed -> final long runTime = System.currentTimeMillis() - startTime;

To ->                long runTime = System.currentTimeMillis() - startTime;

 

and moved it to onPaint smile.png

Edited by Hafdellaren
  • Like 1
Posted

Now it just says 12:45:43 from login screen and aswell when it runs unsure.png

 

EDIT: It works now.

 

Changed -> final long runTime = System.currentTimeMillis() - startTime;

To ->                long runTime = System.currentTimeMillis() - startTime;

 

and moved it to onPaint smile.png

Oh i didn't know u didn't have it in onPaint() anywayz good job :)

  • 2 months later...
  • 2 weeks later...
  • 1 month later...
  • 2 weeks later...
Posted
On 12/2/2015 at 3:54 AM, Explv said:

private Optional<Integer> getPrice(int id){ Optional<Integer> price = Optional.empty(); try { URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); String[] data = br.readLine().replace("{", "").replace("}", "").split(","); br.close(); price = Optional.of(Integer.parseInt(data[0].split(":")[1])); } catch(Exception e){ e.printStackTrace(); } return price; }

Hey i simply dont understand how to implement this code. What imports do i need for it?

Posted
18 minutes ago, Antonio Kala said:

How much cpu would you say having something that calculates gp/hr and runtime use? or would it be negligible? 

runtime would be near negligible but calculating GP/h depends on whether your getting prices from GE constantly and what other calculation your doing. if its a simple calculation also near negligible 

Posted
11 minutes ago, IDontEvenBot said:

runtime would be near negligible but calculating GP/h depends on whether your getting prices from GE constantly and what other calculation your doing. if its a simple calculation also near negligible 

Someone told me paint runs on a separate thread regardless of what it is, and thus it's better if avoided?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...