2D Graphics tutorials

Hey guys, i want to write a 2D FPS. Unfortunatly i dont know much about this sort of programming (i do java at universtiy, but its all swing). Does anyone know of any good tutorials in 2D graphics handling , animation etc?
Thanks Dave

Hi Dave,
If you're still looking for a Java 2D tutorial, try this one . . .
http://www.planetalia.com/cursos/
Hasman

Similar Messages

  • Interactive Graphic Novel

    I'm working on an interactive graphic novel.  It will be made in InDesign and then saved as a PDF/EPUB.  The issue becomes the "interactive" part.  I think AIR is the answer for that.  I want to start with a demo product with some basic interactive capabilites.  My experience with Air is...well lets just say I am looking for some help.  I want the reader to be able to click on any pictures of computers in the novel and get an interface where they can look through files, videos, and eventually a game.  I want to implant Easter Eggs where if the reader clicks on them a secret organization in my world will invite them to join allowing them access to more files in the "computer". 
    This is a science fiction universe we are creating and I will eventually be putting out a series of graphic novels each along a particular story line. 
    I hope it's okay to say that I can pay but not a lot.  Perhaps that's why my search via other avenues has not provided me a suitable candidate.  If this sounds interesting to you and you feel you are capable of creating a "cool" looking interface I would love to talk with you. 
    Here is my website to give you some more information.  www.hellcreeksanitarium.com
    Thank you
    Norm
    HCS

    Thankyou for the reply. I would definetly be interested in learning how to replicate those filters.
    This is the effect of the 'graphic novel' filter: http://www.twistingpixels.graphics/tutorials/2013/6/12/the-graphic-novel-filter-photoshop- elements-diamond-in-the-rough
    'Pen and Ink' in action: https://www.youtube.com/watch?v=xFEp7f_KbZ4
    and 'Comic': https://www.youtube.com/watch?v=SUmKtttJ4J8 (I realize this one is very similar to the 'cutout' filter in full version of PS)

  • Graphic Novel Filters in Photoshop Creative Cloud?

    Hello,
    Will the Graphic Novel, Comic, and Pen and Ink filters introduced in Photoshop Elements 11 being coming to Photoshop CC? I used these quite often with the trial of PS Elements 11, but now that I have a CC subscription, I miss those features.
    So I guess my question is, is there anyway to migrate those over to the full version of PS?

    Thankyou for the reply. I would definetly be interested in learning how to replicate those filters.
    This is the effect of the 'graphic novel' filter: http://www.twistingpixels.graphics/tutorials/2013/6/12/the-graphic-novel-filter-photoshop- elements-diamond-in-the-rough
    'Pen and Ink' in action: https://www.youtube.com/watch?v=xFEp7f_KbZ4
    and 'Comic': https://www.youtube.com/watch?v=SUmKtttJ4J8 (I realize this one is very similar to the 'cutout' filter in full version of PS)

  • Runtime error accessing ArrayList

    These 2 classes are basically the classes from the book developing games in java, without the fullscreen stuff. They are supposed to create an animation. They both compile fine but when I run I get an error message, an no animation, paint() is only called once. Here's the error message:
    Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 4, Size: 4
    at java.util.ArrayList.RangeCheck(ArrayList.java:546)
    at java.util.ArrayList.get(ArrayList.java:321)
    at Animation.getFrame(Animation.java:60)
    at Animation.update(Animation.java:43)
    at AnimationTest1.animationLoop(AnimationTest1.java:58)
    at AnimationTest1.run(AnimationTest1.java:44)
    at AnimationTest1.main(AnimationTest1.java:10)
    I think this means the program is trying to access frame 4 when there is none. Right? I just can't get my brain around this. Any help would be great!
    import java.awt.Image;
    import java.util.ArrayList;
    /*     this class manages a serie of images (frames) and the amount of time to
         display each frame */
    public class Animation {
         private ArrayList frames;
         private int currFrameIndex;
         private long animTime;
         private long totalDuration;
         //creates a new, empty animation, calls start().
         public Animation() {
              frames = new ArrayList();
              totalDuration = 0;
              start();
         //adds an image to the animation, + how long to display the image.
         public synchronized void addFrame(Image image, long duration) {
              totalDuration += duration;
              frames.add(new AnimFrame(image, totalDuration));
         //starts this animation over from the beginning .
         public synchronized void start() {
              animTime = 0;
              currFrameIndex = 0;
         //updates this animations current frame if necessary
         public synchronized void update(long elapsedTime) {
              if (frames.size() >1) {
                   animTime += elapsedTime;
                   if (animTime >= totalDuration) {
                        animTime = animTime % totalDuration;
                        currFrameIndex = 0;
                   while (animTime > getFrame(currFrameIndex).endTime) {
                        currFrameIndex ++;
         //gets the animations current frame. null if none availible.
         public synchronized Image getImage() {
              if (frames.size() == 0) {
                   return null;
              else {
                   return getFrame(currFrameIndex).image;
         private AnimFrame getFrame(int i) {
              return (AnimFrame)frames.get(i);
         private class AnimFrame {
              Image image;
              long endTime;
              public AnimFrame(Image image, long endtime) {
                   this.image = image;
                   this.endTime = endTime;
    import java.awt.*;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    public class AnimationTest1 {
         public static void main (String args[]) {          
              AnimationTest1 test = new AnimationTest1();
              test.run();
         private static final long DEMO_TIME = 5000;
         private JFrame frame;
         private Animation anim;
         public void loadImages() {
              //load images
              Image player1 = loadImage("gif1.png");
              Image player2 = loadImage("gif2.png");
              Image player3 = loadImage("gif3.png");
              //create animation
              anim = new Animation();
              anim.addFrame(player1, 200);
              anim.addFrame(player2, 200);
              anim.addFrame(player3, 200);
              anim.addFrame(player2, 200);
         //loads image with ImageIcon
         private Image loadImage(String filename) {
              return new ImageIcon(filename).getImage();
         public void run() {
              try {
                   frame = new JFrame();
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.setSize(300, 300);
                   frame.setVisible(true);
                   loadImages();
                   animationLoop();
              finally {
         public void animationLoop() {
              long startTime = System.currentTimeMillis();
              long currTime = startTime;
              while (currTime - startTime < DEMO_TIME) {
                   long elapsedTime = System.currentTimeMillis() - currTime;
                   currTime += elapsedTime;
                   anim.update(elapsedTime);
                   //getContentpane.getgraphics??!!
                   Graphics g = frame.getGraphics();
                   draw(g);
                   g.dispose();
                   try {
                        Thread.sleep(20);
                   catch (InterruptedException ex) {}
         //draw the animation
         public void draw(Graphics g) {
              g.setColor(Color.white);
              g.fillRect(0, 0, 300, 300);          
              g.drawImage(anim.getImage(), 0, 0, null);
    }

    106498II wrote:
    i changed it to read:
    while (animTime > getFrame(currFrameIndex).endTime) {
                        currFrameIndex ++;
                        if (currFrameIndex >3) {
                             currFrameIndex = 0;
                        }this gets rid of the error but still no animation. Perhaps its something to do with that I draw directly on the JFrame?On the JFrame? Better to draw in a JPanel or JComponent. Also, perhaps you're trying to animate on the EDT in which case you get the beginning picture, and the end picture but usually you get nothing in between. Are you using a non-EDT thread or a Swing Timer?
    Addendum: yeah it looks like you're trying to put the EDT (event dispatch thread -- the main thread that runs Swing) to sleep here. Please don't do this. Also you're trying to draw outside of a paint or paintComponent method.
    Solution: Run don't walk to the Sun java2D and Swing graphics tutorials and read and study them.
    Edited by: petes1234 on Dec 11, 2007 7:21 PM

  • New to drawing graphs

    I'm trying to plot a graph/chart of 2 lists of numbers, but really have no idea where to start. I imagine what I'm trying to do is read in the data from 2 files (can do this), make some empty chart object (not sure what to use for this), then with each pair of numbers plot the coordinate on a chart.
    Do I need to use applets for this or is there some way an application can generate a file? I would like to start off with a very simple application rather than writing something that goes on the web (as I don't know how to do this with my current computer set up). I'm getting quite confused with all the applet/graphic tutorials I've looked at. They all seem to assume some prior knowledge. I need to start at the very beginning here, HelloWorld-on-a-chart level! Any pointers?
    I do understand basic object oriented java programming, but have absolutely NO experience with graphics :-(

    I do understand basic object oriented java programming, but have absolutely NO experience with graphics :-(Then starting with a data graphing program is not the place to start. Check out the gui trails/tutorials on this site. Also download JGraph and check that out

  • Getting started with illustrator

    hi,
    i dont know the first thing about illustrator, but i know a little about photoshop.
    can someone tell me how to learn about illustrator.
    thanks
    dustin

    Think about the methods that worked best for you when learning Photoshop. Apply the best of what you know about your style of learning, and do the same thing with Illustrator.
    Which things worked best for *YOU*?
    Online text-n-graphic tutorials? Videos? Physical books?
    No matter what, though, you owe it to yourself to get a decent understanding of the basics. This means cracking open the Help files and learning the proper names for the tools and some of the basic functions. Then open up Illustrator, start a document and begin exploring and playing. Try every tool, explore every menu option. Get stuck? Look it up in the Help files.
    By getting the basics downby whichever methods work best for your style of learning, when you need help with specific things at least you'll have a grip on the app. That'll enable you to ask good questions.

  • How can I make a drawing stable and not disappear?

    When I draw some shapes in a panel, if another window goes over the panel, then the drawing disappears and I have to draw it again.
    How can I make the drawing stable?

    Encephalopathic wrote:
    Of course you've read the graphics tutorials, and you are doing all of your drawing in a paintComponent(Graphics g) method override, correct?Encephalopathic is correct. If you want the stuff you draw to persist, you should override paintComponent() and redraw everything there. Just because you've drawn something on a component once (say, a line or an Image) does not mean it'll be redrawn the next time the component needs to be painted. You have to re-draw your custom stuff every time a repaint event is sent to the component, and that means overriding paintComponent().
    If your component will have lots of custom painting done to it (such as if you're making a MS Paint-style program), you might want to consider drawing to a BufferedImage, then in your component's paintComponent() override, just rendering the BufferedImage. Check the documentation for more details.

  • Re: How to go about a problem with JFrame

    first before anything, I suggest you read the Sun Java Swing graphics and 2D graphics tutorials. They'll give you the answers you need including using JPanels, overriding the paintComponent method, etc...
    Next, try to separate your logic from your graphics. It will make updating and debugging a whole lot easier.
    Good luck.

    This is the approach I would (and did) take:
    Extend JPanel
    Have an ArrayList of Shape or any class implementing Shape
    Override paintComponent and iterate over the ArrayList to draw the shapes
    AddMouseListener which iterates over the ArrayList to detect whether any element contains() MouseEvent#getPoint()
    If one is found, take action accordingly. As per your OP, you probably want to perform two different actions alternately, could use a boolean flag for that.
    If (as was the case for me) the shapes may overlap, iterate upwards in the paintComponent and downwards in the MouseListener so that the first shape detected is the last drawn (the topmost). Break out of the iteration if you want only one shape to be detected.
    db

  • Draw image to JPane in NetBeans

    I am developing a GUI in NetBeans that is for changing the settings.
    one setting is a username and password.
    once the user has inputed a username and password it needs to show a GIF image which is a loading kinda circle thing that goes around i don't have a problem with knowing when to show the image and start the request it is just the showing the image bit at the moment i have this code:
    public ConfigGUI() {
         initComponents();
         center();
         System.out.println("Loading image");
         Graphics loginGraphics = loginPane.getGraphics();
         LoadImageApp image = new LoadImageApp("resources/strawberry.jpg");
         loginGraphics.drawImage(image.img, 1, 1, null);
         loginPane.repaint();
         loginPane.setVisible(true);
         System.out.println("Image loaded");
        /* image class */
        public class LoadImageApp extends Component {
         BufferedImage img;
         //@Override
         public void paint(Graphics g) {
             g.drawImage(img, 0, 0, null);
         public LoadImageApp(String filename) {
             try {
              img = ImageIO.read(new File(filename));
             } catch (IOException e) {
              System.out.println("Failed to load image");
         //@Override
         public Dimension getPreferredSize() {
             if (img == null) {
              return new Dimension(100, 100);
             } else {
              return new Dimension(img.getWidth(null), img.getHeight(null));
        }but it doesn't work.
    am i using the right kind of components or do i need to use something other than a JPane?
    and what code should i be using to output the image?
    Scott.

    If you're using Swing here, I wonder if you should draw in either a JPanel or a JComponent, but not in a Component. Also, if you do use either JPanel or JComponent, then you should override the paintComponent method not paint. If this suggestion doesn't help, then consider posting an [SSCCE,|http://sscce.org] but if you do so, I recommend that it be very very simple and not be NetBeans-generated.
    Good luck.
    edit: on second look your code looks a little odd. Why are you loading an image into a component but not viewing it in that component, but instead pulling out the image variable and using it elsewhere? It looks a bit strange but perhaps you have a good reason for doing it this way? Have you read the Sun graphics tutorials yet? if not, they are quite well written.
    Edited by: Encephalopathic on Nov 20, 2008 5:07 PM

  • Adding shapes to a GUI

    Hi all,
    Im just starting out producing a GUI and im using netbeans to help me.
    I need to add shapes to my GUI, just basic square, circle etc for now. I also need to show these shapes moving around the GUI, animated.
    Firstly what is the best way to add these basic shapes to a jpanel and secondly how do i go out moving thse objects around the jpanel.
    Thanks for your help

    Puce,
    Thanks for your help.
    I have been through the 2d graphics tutorials and had a look at them but i am still having problems.
    I want to add the shape to an existing jpanel on a GUI containing several jpanels.
    I am unsure where the code for this goes as in the tutorial it just has a seperate class for a single panel which then seems to overide the paintcomponent method. Where would i do this in my single class for the whole GUI.
    Thanks Again

  • How to achieve Transparancy

    Hello,
    I want to achieve transparancy in my applet window so how i can achieve it/
    In a Broswer i have Some links for different Graphical tutorials.
    In that browser i have one link by clicking that i have to open New window which can be Applet, html etc..
    In New window i have an object (for eg. An Image of tutor which is animatation) Now i want something like
    There are two layer now in 1st Layer i have all the links for different tutorials,
    In New open window i have Animated image. Now i want to make it transparent so i can see the Links from the web page and click on othere links.
    Just the image part should be occupy and in other parts i can click on any link.
    Can anyone suggest me what approach i should i use to achieve it.
    Thanks in Advance
    Sandip

    I hope there might be some simple way to do this and waiting for experts to reply.
    Try the below query.
    SQL> select * from random_numeral;
      NUMERALS
             1
             2
             3
             4
             5
             6
            56
            85
            24
            11
           120
      NUMERALS
           114
           100
           140
    14 rows selected.
    SQL> select a.numerals ||' / '||b.numerals||' / '||c.numerals from
      2          (select numerals,rownum rn1 from
      3          (
      4              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
      5              from random_numeral
      6          )
      7          where rn=1) a,
      8          (select numerals,rownum rn1 from
      9          (
    10              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
    11              from random_numeral
    12          )
    13          where rn=2) b,
    14          (select numerals,rownum rn1 from
    15          (
    16              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
    17              from random_numeral
    18          )
    19          where rn=0) c
    20  where   a.rn1=b.rn1(+)
    21  and b.rn1=c.rn1(+)
    22  /
    A.NUMERALS||'/'||B.NUMERALS||'/'||C.NUMERALS
    1 / 2 / 3
    4 / 5 / 6
    11 / 24 / 56
    85 / 100 / 114
    120 / 140 /
    SQL>Cheers,
    Mohana

  • GUI JLabel Problem

    Hello, I am a noob and i will admit it. I have been at it for a few hours now trying to figure out how to....
    1.) Add JLabels to a GUI with a Background painted on it using the paint(); method without it being retarded
    2.) Update the gui with paint(); and have it not flash (I've tried using update with double buffer)
    Can someone lead me in the right direction?
    Here's my code..
    import java.util.*;
    import java.net.*;
    import javax.swing.*;
    import java.io.*;
    import javax.swing.JOptionPane;
    import java.awt.*;
    import java.awt.event.*;
    public class PingPongGUI extends JFrame implements KeyListener
         private Image dbImage;
         private Graphics dbg;
         double p1score=0;
         double p2score=0;
         String p1scoreStr="";
         String p2scoreStr="";
         ImageIcon backImage = new ImageIcon("ping-pong-medium.jpg");
         JLabel Player1L = new JLabel("Test Label");
        public PingPongGUI() throws Exception
              this.setFocusable(true);
             this.addKeyListener(this);
            setTitle("Ping Pong Leagues (Beta Version 1.0) : Developed by ME. || ANDREW IS A BOCE!");
            setSize(800, 600);
            setResizable(false);
            Container pane = getContentPane();
            pane.setLayout(null);
              //Adding stuff to the GUI
              //pane.add(Player1L);
              //GUI Preferences
            setVisible(true);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
        public static void main(String[] args) throws Exception,AWTException,IOException
            PingPongGUI PPGUI = new PingPongGUI();
        public void paint(Graphics g)
              super.paint(g);
              //Drawing the scores on the window
              g.drawImage(backImage.getImage(), 0, 0, 800, 600, null);
              java.awt.Font font = new java.awt.Font("Arial Narrow",1,20);
              //Set Labels Overtop of background image
              Player1L.setFont(font);
              Player1L.setForeground(Color.blue);
              Player1L.setSize(40, 40);
              Player1L.setLocation(30, 50);
              //Player1L.setOpaque(true);
              Player1L.setVisible(true);
         public void update(Graphics g)
                   //Double Buffering to insure no flash when movment occurs
                   // initialize buffer
                   if (dbImage == null)
                        dbImage = createImage (this.getSize().width, this.getSize().height);
                        dbg = dbImage.getGraphics ();
                   // clear screen in background
                   dbg.setColor (getBackground ());
                   dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
                   // draw elements in background
                   dbg.setColor (getForeground());
                   paint (dbg);
                   // draw image on the screen
                   g.drawImage (dbImage, 0, 0, this);
    }Edited by: JavaOwnsFace on Mar 6, 2009 8:28 PM

    You will benefit greatly by going through the Sun graphics tutorials. There you will learn not to paint directly to a JFrame (similar for JApplet) but instead to a JComponent or JPanel. Also, you appear to be using your paint method to do program logic and this is definitely a very bad thing to do as you cannot control when a paint method will be called. Again, the tutorials should help you with this too.

  • FIRST GAME COMPLETE!!!

    It is kind of like Duck Hunt but obviously not as cool. If anyone wants to take a look at it heres the link:
    [http://apollo.occc.edu/java80/Game.html|http://apollo.occc.edu/java80/Game.html]
    Let me know what you guys think!
    If anyone knows of an easy way to add background images to panels, let me know haha.

    sam_misled wrote:
    It is kind of like Duck Hunt but obviously not as cool. If anyone wants to take a look at it heres the link:
    Let me know what you guys think!Nice job on your first game. Where's the source?
    If anyone knows of an easy way to add background images to panels, let me know haha.This is easy to do. All you need to do is override the JPanel's paintComponent and draw the image using the Graphics object handed to you via the method's parameter. Be sure though to call super.paintComponent(g) first though. Now how you get the image will depend on the program. If you currently have a JAR file, then you may do well to package the images with the JAR file and obtain the image via getResource() method call, or you could get your image from the web,... But most important: check the Sun Graphics tutorials and search these forums for many examples. Good places to search include the Swing forum and the Graphics forum.

  • Drawing issues

    I create a jframe and a jpanel and try to add graphics to the jpanel (I also tried the jframe) but the graphics do not come up. What am I doing wrong? The code that I have is:
    public void showStats(){
              Graphics g;
              JFrame tframe = new JFrame();
              JPanel p = new JPanel();
              tframe.setSize(200,200);
              tframe.add(p);
              tframe.setVisible(true);
              p.setLayout(null);
              g = p.getGraphics();
              g.setColor(Color.red);
              g.fillRect(10,10,50,50);
         }When a button is clicked it calls this method.

    Tyler0976 wrote:
    I create a jframe and a jpanel and try to add graphics to the jpanel (I also tried the jframe) but the graphics do not come up. What am I doing wrong? It's all wrong as you don't get graphics via getGraphics, you use a paintComponent override in your JPanel. Please read the Sun graphics tutorials for details.

  • Tutorials on Header Graphics

    Hi,
    Could I please have some good tutorials on how to make good header graphics?
    I'd appreciate it. Thanks in advance!

    There is nothing special about header graphics – they are just a wide, rectangular image inserted in the top of the document, whether it is for web or print.
    I suggest you try an internet search for photoshop tutorials.
    (Or look for templates to get some ideas.)

Maybe you are looking for