Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

208 Neutral

About KenWill

  • Rank
  1. KenWill

    Making a camera

    When i said i want to move the background, that's what i meant. Make the map as a movieclip and then move it around when i have to and all the other stationary objects or otherwise to position themselves relative to the map.
  2. KenWill

    Making a camera

    AS3 without any library.
  3. KenWill

    Making a camera

    Hi. I want to implement a camera in my game...but i have no idea how to do it. The only way i could think of is moving the actual background of the game and not the player itself and only move the player and not the background when its not too close to the edge. Is this how is done? How else can one simulate a camera that moves the view without moving the background?
  4. KenWill

    Making objects solid

    In AS3 i made some blocks that follow the player around. But the problem is, as the player moves around, the objects merge together and at one point you can't tell how many objects are on the screen. How do i make them solid so they cannot overlap each other. I am using 10 objects, they are all in an array and they are created and destroyed dynamically so i don't really know how i should try to fix this.  
  5. I did this before and it worked as intended but now i just can't seem to get it working. I know my code is not the problem because i tested it on the same panel and it worked. For me it looks like focusGained function is never called and that's why its not working. Here is the code: public void initialize(JPanel editPanel, JPanel propertiesPanel) { this.editPanel = panel; this.propertiesPanel = propertiesPanel; panel = new JPanel(); initializeProperties(); panel.setBounds(0, 0, 340, 340); panel.setLayout(null); panel.setBorder(BorderFactory.createLineBorder(, 1)); panel.addMouseMotionListener(new MouseMotionListener(){ @Override public void mouseDragged(MouseEvent me) { xPos = panel.getX() + me.getX() - panel.getWidth()/2; yPos = panel.getY() + me.getY() - panel.getHeight()/2; // CHECK IF OUT OF BOUNDS if(xPos < 0) { xPos = 0; } else if(xPos >= editPanel.getWidth() - panel.getWidth()) { xPos = editPanel.getWidth() - panel.getWidth(); } if(yPos < 0) { yPos = 0; } else if(yPos >= editPanel.getHeight() - panel.getHeight()) { yPos = editPanel.getHeight() - panel.getHeight(); } panel.setLocation(xPos, yPos); } @Override public void mouseMoved(MouseEvent me) { } }); panel.addFocusListener(new FocusListener(){ @Override public void focusGained(FocusEvent e) { // propertiesPanel.removeAll(); propertiesPanel.add(widthLabel); propertiesPanel.add(widthField); propertiesPanel.add(heightLabel); propertiesPanel.add(heightField); propertiesPanel.add(backgroundColorLabel); propertiesPanel.add(backgroundColorField); propertiesPanel.add(backgroundImageLabel); propertiesPanel.add(backgroundImageField); propertiesPanel.add(transparentCheck); propertiesPanel.add(borderTypeLabel); propertiesPanel.add(borderTypeComboBox); propertiesPanel.add(borderWidthLabel); propertiesPanel.add(borderWidthField); propertiesPanel.add(borderRadiusLabel); propertiesPanel.add(borderRadiusField); propertiesPanel.add(paddingLabel); propertiesPanel.add(paddingField); propertiesPanel.repaint(); } @Override public void focusLost(FocusEvent arg0) { // TODO Auto-generated method stub } }); editPanel.add(panel); editPanel.repaint(); } private void initializeProperties() { widthLabel = new JLabel("Width"); widthLabel.setBounds(24, 11, 46, 14); widthField = new JTextField(); widthField.setBounds(126, 8, 60, 20); widthField.setColumns(10); heightLabel = new JLabel("Height"); heightLabel.setBounds(24, 36, 46, 14); heightField = new JTextField(); heightField.setBounds(126, 33, 60, 20); heightField.setColumns(10); backgroundColorLabel = new JLabel("Background Color"); backgroundColorLabel.setBounds(10, 61, 86, 14); backgroundColorField = new JTextField(); backgroundColorField.setBounds(126, 58, 60, 20); backgroundColorField.setColumns(10); backgroundImageLabel = new JLabel("Background Image"); backgroundImageLabel.setBounds(10, 86, 101, 14); backgroundImageField = new JTextField(); backgroundImageField.setBounds(106, 83, 80, 20); backgroundImageField.setColumns(10); transparentCheck = new JCheckBox("Transparent"); transparentCheck.setBounds(24, 107, 97, 23); borderTypeLabel = new JLabel("Border Type"); borderTypeLabel.setBounds(10, 137, 86, 14); borderTypeComboBox = new JComboBox(); borderTypeComboBox.setBounds(106, 134, 80, 20); borderWidthLabel = new JLabel("Border Width"); borderWidthLabel.setBounds(10, 162, 63, 14); borderWidthField = new JTextField(); borderWidthField.setBounds(126, 159, 60, 20); borderWidthField.setColumns(10); borderRadiusLabel = new JLabel("Border Radius"); borderRadiusLabel.setBounds(10, 187, 86, 14); borderRadiusField = new JTextField(); borderRadiusField.setBounds(126, 184, 60, 20); borderRadiusField.setColumns(10); paddingLabel = new JLabel("Padding"); paddingLabel.setBounds(10, 212, 46, 14); paddingField = new JTextField(); paddingField.setBounds(126, 209, 60, 20); paddingField.setColumns(10); }
  6.     Some systems do it one way, some systems do it another way.   The mouse coordinates need to be relative to something.  "Relative to" means the location where (0,0) is at.   Often they are relative to the top left corner of the screen.  screen-upper-left.PNG   Many old systems in the 1970s and 1980s had mouse positions relative to the bottom left corner of the screen. screen-lower-left.PNG   Many systems can get mouse positions relative to a specific window. This is probably the corner used in your code's button.setLocation(). window-top-left.PNG   Other times the position is relative to a specific panel control-top-left.PNG   Other times the position is relative to a specific button or UI control.  This is probably the corner used in your code's e.getX() and e.getY(). button-relative.PNG   Different systems choose different locations, and where the (0,0) position is centered depends on what object is listening to the event and how the system is implemented.     In the case of your code: x = button.getX() + e.getX(); y = button.getY() + e.getY(); button.setLocation(x,y); Probably e.getX and e.getY are getting the position relative to the button. This is like the final image above.    Then the programmer wants to turn it back into a position relative to the entire screen, so they add the button's screen position to the mouse position relative to the button position.   Thanks a lot! That makes a lot more sense now. :3
  7. Is that the container that holds the component? Like a JPanel? And also what does "relative to" mean? Sorry, but english is not my first langauge.
  8. x = button.getX() + e.getX(); y = button.getY() + e.getY(); button.setLocation(x,y); What i'm confused about are the first two lines. How does that work? Lets say the button x coordinates are 34 and the mouse x coordinates are 37, isn't that a total of 71 when you add it up? Then how does this work? Only setting them to the mouse's position makes the button go crazy when moving but i noticed that it goes away from the mouse position. Does e.getX() return the distance from the button coordinates(which are in the upper corner) to the mouse coordinates?
  9. I wanna check if a button has been pressed or the mouse is over a component in my logic loop but i can't find any function for this and i don't wanna have to split up code in different files because i want to have my components interact with each other and with other classes and its just doesn't feel right and its also annoying to have to pass references to objects everywhere. Bloody hell Swing its annoying... How can i do this?   EDIT: Nevermind i think i just figured it out by myself...
  10. Python - best for scripting, not games C++ - well, its a industry standard for a reason. Its fast, kinda hard to get the hang on for beginners but you have a programming background so i think learning it will be easy for you, allows you to do things that Java or Python for example wouldn't and its the best choice for 3D games (IMO) with libraries like SDL Java - good for 2D games (IMO) and applications, easy to learn, easy to use, lots of libraries and tutorials but its a little bit slower than C++ and i wouldn't use it for 3D games
  11. KenWill

    Time button is pressed

    i just want a code that let me calculate time button is pressed on my computer keyboard   But why do you want that? There are a lot of ways to do it. Easy ways like using a library, and hard ways like writing everything yourself. We can't give you code without you specifying what language you're using or if you're using a library.
  12. KenWill

    Time button is pressed

    Its simple but if you want a code example you should specify what you're using. You just need a way to store time and to tell if the key is down or the key is up. if(isButtonDown()) { clock.start(); } if(isButtonUp()) { clock.stop(); }
  13. KenWill

    Making bots with python

      I didn't think people will see me as an evil bastard for not specifying what i wanna do with the bot. I do not want to screw up anyone in anyway and neither cheat at a game, i don't even know where and if i'm gonna use this script. I just wanna know if there are some things that i can automate using a script. If you can, just an "yes" or "no" would be enough.
  14. Can i make a bot that goes to random pages of a site and when encounters something on that page, clicks on it and then does the same thing over and over again in python? I assume python would be the kind of language this could be built in, if there are better solutions please tell me.
  15. KenWill

    C++ Webpage inside a program

    Jesus...I'm just trying to make a web page appear in my application window.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!