Jump to content

Explv's Dank Paint Tutorial


Explv

Recommended Posts

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.

Link to comment
Share on other sites

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);
Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 1 month later...
  • 2 weeks later...
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?

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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