# PsionicTransvection

Members

20

262 Neutral

• Rank
Member
1. ## Projectile Motion (Parabola)

So here is the thing Im working on a small game which it looks like this [img]http://public.gamedev.net/uploads/monthly_08_2012/post-195425-0-37618500-1345207703_thumb.png[/img] there are 2 tanks shooting at each other in turns and you are supposed to change the angle (moving arrow up or arrow down) and the power with which the projectile is flying (holding down the space the longer you hold the more power the projectile gets). So far managed to make a small figure moving around the screen and shooting but until this point I made it shoot only in a straight line searched a lot of links and videos about this problem I found the formulas needed for calculating the curve but still have problems applying it in my code :/ Im open to any suggestions or criticisms Im sure Im doing something wrong all advices and code examples will be gladly appreciated looking forward for your posts I really need help with the parabola problem . Here is the shoot method which makes the projectile move its a rectangle : (sorry for not putting the code in tags for some reason when I do it does not print the whole code) public void shoot() { if (shot) { bullet.x -= 5; bullet.y--; System.out.println(bullet.y); if (bullet.x <= 0) { readyToFire = true; System.out.println("Boom"); boom = true; //power = 0; } } } I also attached a rar with the whole code so far its only 2 classes its not much
2. ## Moving an image

[CODE]import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.*; public class View extends JFrame implements KeyListener { JPanel jp = new JPanel(); JLabel jl1 = new JLabel(); ImageIcon img = new ImageIcon(getClass() .getResource("/images/Standing.png")); static int Xposition = 0; static int Yposition = 300; public View() { setTitle("GG"); setSize(800, 600); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); jp.setLayout(null); setLocationRelativeTo(null); jl1.setIcon(img); jp.add(jl1); jl1.setBounds(Xposition, Yposition, jl1.getIcon().getIconWidth(), jl1 .getIcon().getIconHeight()); add(jp); validate(); } public static void main(String[] args) { View view = new View(); } @Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); } @Override public void keyReleased(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } }[/CODE] once I have loaded an image into the JFrame how can I make it move with the arrow keys I saw some tutorials how to do it if you draw a figure yourself but how to do with an actual image you have loaded ?
3. ## Problem with JAVA ImageIcon

fixed it had to import the images through Eclipse omg
4. ## Problem with JAVA ImageIcon

any other ideas ?

same thing
6. ## Problem with JAVA ImageIcon

same exception different line in another program I have done the assignment the same way outside the constructor checked path everything still getting the NullPointerException
7. ## Problem with JAVA ImageIcon

[CODE]import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class View extends JFrame { JPanel jp = new JPanel(); JLabel jl1 = new JLabel(); ImageIcon figure = new ImageIcon(getClass().getResource("/blank.png")); // I get the exception here public View(){ setTitle("test"); setSize(800, 600); setResizable(false); setVisible(true); setLocationRelativeTo(null); jl1.setIcon(figure); jp.add(jl1); add(jp); jl1.setBounds(0, 0, jl1.getIcon().getIconWidth(), jl1.getIcon() .getIconHeight()); validate(); } public static void main(String[] args){ new View(); } }[/CODE] for some reason I cant fetch the image and the path and name is correct checked it several times and the funny thing is Im doing it by checking some old code of mine and there is working perfectly ... This is the exception I get any Ideas ? Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:167) at View.<init>(View.java:14) at View.main(View.java:30)
8. ## OpenGL vs DirectX ?

Could you tell me which one is better to use ?
9. ## Modeling and coding

thank you for shedding some light on mu incompetence can you suggest me some more reading about it or give a some very simple example e.g. some chunk of code
10. ## Modeling and coding

So my question is when you make some 3D model or some 3D animation on lets say 3D studio max and after that when you export it or something how do you actually connect it the source code of the game ?
11. ## UDK

I just have a question about the UDK. Is it considered an industry standard of some sort ? Are there companies making games entirely on UDK or they are just using the Unreal engine sorry for the relatively stupid question but Im curious.
12. ## Math and 2D game development

can you guys give me a simple example a chunk of code for what complex numbers can be used ?
13. ## Math and 2D game development

Yeah I know that video game development is not easy at all but I have to start from somewhere
14. ## Math and 2D game development

Hello there sorry for the silly question but I prefer some advices than just going ahead. Recently I started learning how to make simple 2D games. First one I made was tic tac toe and then I started working on pong but its not finished yet. Im pretty much aware that math is quite an important part of video game development and I just want to ask you guys which branches of mathematics are the most vital ones when it comes to 2D game development .. Lets say for example a simple side scrolling game with a very basic physics engine. And what math/physics will it be required in order to . lets say make it smoother and with better physics , sorry again for the lame question its just I feel quite confused atm.Really looking forward to your replies !
15. ## Problem with Background (JAVA)

I wrote a class that is suppose to draw a red rectangle in a JPanel with and the background of the panel is suppose to be black here is my code [code]import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Color; import java.awt.Graphics; public class View extends JFrame { private JPanel panel = new JPanel(); public void paint(Graphics g) { g.setColor(Color.RED); g.drawRect(20, 50, 100, 100); } public View() { setSize(640, 480); setResizable(true); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setBackground(Color.BLACK); panel.setSize(640, 480); panel.setBackground(Color.BLACK); panel.paint(null); this.add(panel); } public static void main(String[] args) { View view = new View(); } }[/code] and here is what I get as a result there appears to be some glitch in the background [attachment=7847:WTF.PNG] (this is a screen of the gui from my code not a minimized Eclipse) and here is how it is without the paint method it does as it suppose to making a window with a black background [attachment=7848:without paint method.PNG] Is it something wrong with my code that it does like that or there is something wrong with my computer ?