• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the best way to create points on a screen and make them interactive using Java

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am making a game where the user is given a letter on screen.

What is the best way to make these letter appear on screen.

The user then uses the mouse to draw from one point to another to connect them together to form the shape of the letter.

I wanted to know what is the best way for the program to create these points so that they appear on screen for the user to interact with them?

I have a canvas and the mouse is able to draw on the screen, the problem is I don't know the best way to create the dots/points on the screen and how to make the points interact-able with the mouse, so that when the mouse draws on or over the dots that it connects them together to form the letter.
VKVcS.png
[Thumbnail for VKVcS.png]
A sample letter
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Assuming that you are using Swing, there really isn't an automatic system (such as sprites), that will take care of hit detection (and perhaps, some placements) for you. You are responsible coding the position of the dots, the drawing of the dots, the hit detection of dots, etc.

Henry
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

As Henry said, you have to write the code to make the computer do all that. This is why programming is both challenging and fun. If you can figure out how to make the computer respond to user gestures and react in ways that simulate some kind of "intelligence" in setting an anchor when the user clicks on a dot, drawing a line when the user "drags" the mouse after creating an anchor point, then "attaching" the end of that line to another dot when the user releases the mouse button after dragging, then you're on your way to finding the answer to your question.

Just displaying dots on the screen that are positioned in a way that approximates the shape of the capital letter A is something that requires some thought, calculation, and perhaps some fancy programming.

Good luck!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic