Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use litiengine for a demonstrator #747

nightm4re94 started this conversation in Old Forum
Discussion options

This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022).
Posted: 2021年05月01日 13:38:21
User: deb75 [] (age: 548 days 🙌; posts: 1)

Hello,
In a java project, I am asked to develop some illustrations for a demonstrator which is quite close to a game,
so I am interested in liiengine. The difference with a game is that there would not have interactions with a player.
Events would be read from a file which is a result from a simulation.
The only constraint I was given is that I have to put the illustration within a jpanel. Is it possible
to make the 2d game engine litiengine work inside a jpanel ?
Also, I would like to

  • make tooltips appear on hovering on some objects
  • zoom in/out and move the drawn surface with the mouse, much like playing with a map
  • catch mouse keyboard events
  • display small jpg/png like icons and be able to move them
  • detect when two objects collides
  • draw easily simple geometric forms
    I would be grateful to you if you could indicate me to what extent litiengine can answer to my needs
    In addition, I retrieved tiles (*png) from openstreetmap for a whole european country at every level zoom.
    I would like to use these one as the background of the illustration and be able to zoom in/out just like on google maps. Do you know if it is handable with litiengine ?
    Best regards
You must be logged in to vote

Replies: 2 comments

Comment options

This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022).
Posted: 2021年05月04日 16:08:47
User: nightm4re [Admin 👑, Mod 🔧] (age: 1567 days 🔥; posts: 185)

Hi and welcome!
First of all, I really like what you're trying to achieve and I assume this kind of endeavour has not been tested out previously.
It is absolutely possible to render a LITIENGINE game within a JPanel, however I cannot currently see the benefit of that. What would that scenario look like? Currently we have a GameWindow which is basically a wrapper for a JFrame that contains a java.awt.Canvas. If you want, you could simply add Game.window().getRenderComponent() to your JPanel to have the game rendered there:

// initialize your game first ...
 JFrame frame;
 JPanel panel;
 frame = new JFrame();
 frame.setTitle("My JFrame");
 frame.setSize(800, 600);
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 panel = new JPanel();
 panel.add(Game.window().getRenderComponent());
 frame.add(panel);
 frame.setVisible(true);

For all your sub-questions, it's a clear yes, you can!. The only thing that would need custom logic would be the zooming behaviour that switches the tiles of your map depending on the current zoom level, but that is a manageable task.
If you need assistance with the specific tasks, let us know in posts dedicated to the problem you're trying to solve.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /