Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: Jump N Run

  1. #1
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default Jump N Run

    Hey guys,
    i have been programming for some time at school with java and now i started a project:
    a simple Jump N Run game. I already managed to build a simple Map editor, but there is a Problem..
    My plan was to do it with squares.. which i can color how i want... i wanted to do it REALLY simple :P

    now i did a class Editor with a atribute squares[200][20] but there should only always be [40][20] on the screen.. so i have to delete the first row and get the next row in, if i want to see the field [1-41][1-21] and do this again so i can see [2-42][2-42] ... i hope you know what i mean..
    ill post a picture here so you will see.. i hope

    these ill see at start:



    these ill see later:


    but at the same position..
    i hope you can help me
    The .jar file where you can get my idea

    this is the .jar file, so you might have an idea what i mean.. you can draw with a and pick a color with number 0-9 .. and i wanted to code, that if you go to the left and right border, there will come more squares ... i hope you know what i mean... like in mario games... :D

    thanks for you help already.. im open for any ideas! please!

    edit: you also might be interested in the system my program works right now..
    i have a class Editor which has int pickedX and int PickedY as position marks for the curser, where im drawing right now.
    the squares have int xWert and int yWert as atributes so i can see their position in the whole [200][20] database..
    Last edited by Coold0wn; 08-05-2011 at 11:08 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    my question is: how can i do this? :P
    i mean.. how can i make the [40][20] array walk to the left and right over the [200][20]..
    i dont know how i should explain that...
    i just ... wrote the answer.... i need a second arrylist.... omg
    i hope that will work... xD

    well my problem was that i only wanted to show a part of the [200][20] array.. and this part should be flexible..
    i hope it will work with a second array... if not, ill be back soon :)

  4. #4
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    doesnt work doggammit... some ideas? :/

  5. #5
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    okay.. i have now an arraylist: Quadrat[100][20] => felder[][]
    and one: Quadrat[40][20] => anzeige[][]

    my anzeige[][] should get a part of the list felder[][] and show it to us.
    by moving to the right border it should show the next row and delete the first,
    if you then go back to the left border, it shows the previous row and deletes the last one.

    but .. i have some trouble..
    public void anzeigeNachLinks() // should delete the last row and put in the previous
    {
    for(int x = 0; x < 40; x++)
    {
    for(int y = 0; y < 20; y++)
    {
    anzeige[x][y] = felder[x+linksoben-1][y];
    }
    }
    linksoben--; // links oben = integer which tells you the number of the first row shown in the felder[][]
    for(int x = 0; x < 40; x++)
    {
    for(int y = 0; y < 20; y++)
    {
    anzeige[x][y].nachRechtsBewegen(); // moves all squares 10px to the right
    }
    }
    }

    public void anzeigeNachRechts() // should delete the first one, and but in the next row
    {
    for(int x = 0; x < 39; x++) // 40?
    {
    for(int y = 0; y < 20; y++)
    {
    anzeige[x+1][y] = anzeige[x][y];
    }
    }
    for(int y = 0; y < 20; y++)
    {
    anzeige[linksoben+39][y] = felder[linksoben+40][y];
    }
    linksoben++;
    for(int x = 0; x < 40; x++)
    {
    for(int y = 0; y < 20; y++)
    {
    anzeige[x][y].nachLinksBewegen();
    }
    }
    }
    whats wrong here? ... :/ do you know?
    Last edited by Coold0wn; 08-06-2011 at 01:51 AM.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    i have some trouble..
    Please explain. Are there error messages?
    Or are the results incorrect? Show how you know that the results are incorrect. Print the variables and add an explanation.
    whats wrong here?
    Too many "magic" numbers. Your code has too many hardcoded literals like 20 and 40. These should either be variables or properties of the arrays the code is working on.

    Please edit you code and wrap it in code tags to preserve the formatting. See:http://www.java-forums.org/misc.php?do=bbcode#code
    Last edited by Norm; 08-06-2011 at 02:36 AM.

  7. #7
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    i made it... after about 15 hours work , the editor is finished :D
    File-Upload.net - Jump-N-Run-Editor-.jar

    here you can see my awsome pixel-editor :DDDD

  8. #8
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    hi, i have another problem to be solved..
    Java Code:
    import java.io.*;
    
    public class SchreibeInDatei {
    
      public void speichern() throws IOException{
        String text = " 1 1 14 0 -2 3 1 \n 1 0 2 3 4 5 24 111 -24 \n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40";
        String dateiName = "Welt1.txt";
        FileOutputStream schreibeStrom = new FileOutputStream(dateiName);
        for (int i=0; i < text.length(); i++){
          schreibeStrom.write((byte)text.charAt(i));
        }
        schreibeStrom.close();
      }
    }
    this would be my code to safe a String in a .txt
    but offortunatly i cant do the method "speichern" from another classobject.

    Java Code:
    public class schreiben
    {
        private SchreibeInDatei d;
        public schreiben()
        {
            d = new SchreibeInDatei();
            d.speichern(); // => cannot find symbol - method speichern();
        }
    }
    it says: cannot find symbol - method speichern();

    you have some idea? i think its because of this 'throws IOException'
    i got that from the internet.. and if i delete it, theres another failure-message..

    edit: i wanted to make the class which wants to safe sth, to give the SchreibeInDatei class a string by speichern(String s)... but that is the easiest problem..
    Last edited by Coold0wn; 08-06-2011 at 06:31 PM.

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    it says: cannot find symbol - method speichern();
    Java Code:
            d = new DateiLesen();
            d.speichern(); // => cannot find symbol - method speichern();
    Is the speichern() method defined in the DateiLesen class? The compiler can not find it there.

  10. #10
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    sure:
    public void speichern() throws IOException

    or does the throws IOException change something to that?

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    The throws clause does not make it so the compiler can not see it.

  12. #12
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    oh.. okay.... and how can i now open that one with another class? Oo
    impossible? .. :/

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    how can i now open that one with another class
    Please explain and show an example in java code of what you are trying to do.

  14. #14
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    oh i messed sth up in this example..
    Java Code:
    public class schreiben
    {
        private SchreibeInDatei d;
        public schreiben()
        {
            d = new SchreibeInDatei();
            d.speichern(); <== ureported exception java.io.IOException; must be caught or declared to be thrown
        }
    }
    thats what it should look like..
    and now the mistake is the same as what i had befor..:
    ureported exception java.io.IOException; must be caught or declared to be thrown

  15. #15
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    i want to open the speicher() method from the class "SchreibeInDatei" with my class "schreiben"

  16. #16
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    ureported exception java.io.IOException; must be caught or declared to be thrown
    Wrap the line(s) of code where that error message is with a try{}catch() block.

    Read in the java tutorial about exceptions: The Really Big Index
    Go to the site and find Extensions in the Essential classes section.

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    i want to open the speicher() method from the class "SchreibeInDatei" with my class "schreiben"
    Get a reference to an instance of the SchreibeInDatei class and use that to call the method:
    <reference to SchreibeInDatei>.speicher();

  18. #18
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

    Default

    that wouldnt be the problem :P
    the speichern() method throws IOExceptions which makes it impossible to a reference..
    it should work with some try catch stuff... i dont know what that is..

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,581
    Rep Power
    25

    Default

    try catch stuff... i dont know what that is..
    See my post #16

  20. #20
    Coold0wn is offline Member
    Join Date
    Aug 2011
    Posts
    71
    Rep Power
    0

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2011, 03:52 AM
  2. jump to args-field in Main method
    By argus in forum New To Java
    Replies: 7
    Last Post: 10-07-2010, 04:14 PM
  3. creating a jump
    By pizzadude223 in forum Java 2D
    Replies: 6
    Last Post: 07-21-2010, 05:01 PM
  4. Eclipse- jump to method definition
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-07-2007, 03:34 PM
  5. To truncate jump of line in jsp
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-09-2007, 03:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •