In my quest to make a simple roguelike, I now have 2 very rudimentary sketches. 1 makes random rectangles appear on the screen, and one lets a player move @ around the screen. Now I would like to work on having the random rectangles not overlap, and @ not be able to move out of the rectangles.
So, I am wondering if the shape functions keep track of their coordinates, and whether this can be accessed somehow. I.e., if I make a line from x1 --> x10, can I get the line function to return the xs 1 --> 10. Otherwise, I plan on making an array of the coordinates from the x,y,w,h arguments I supply when the rectangles are formed (the rectangles are currently room objects). This would be redundant if I could just use the information from the rect() function (if it exists), e.g., dump the perimeter of the rectangle into a list which would become a part of the particular room object. Then, I when @ moves to cross the boundary of the room object, I could check the x,y, first. I also plan to use this data to prevent the rooms from overlapping (as they currently do, since they are supplied random x, y coords). Below are the two sketches (very basic, but they do what I ask, and I understand the code contained).
So, I am trying to make a roguelike in Processing. The first thing I am working on is building a map. My end goal is to have rooms that have random locations and dimensions, and (eventually) themes. They would also be lit or dark, have different environmental statuses, etc. For now, they just have random x,y,w,h. In any case, I started out by building off of the array of objects example. Below is my code so far:
The idea here was to make an array of room objects, and then display them. I get an error with the Room.display() line in draw(). "Cannot make a static reference to the non-static method display()..." Not sure why I am getting this error.
Also, I wasn't sure if objects could supply their own parameters. In other words, should my code for deciding on the random x,y,w,h be a method inside the class or should it be outside (as I attempted, here). Anyway, advise would be appreciated. Thanks!
New to the forum, and new to Processing, but not new, per se, to programming. I have tried to learn many languages, from Python...C++...Common Lisp and many others. The failing point for me is the jump between the tutorials and making something myself.
I would like to make a roguelike for 2 reasons: 1)Just because, and 2) because I think that having a project to work on, more complex than the common programming tutorial, will help me actually learn to program.
I would like to hear feedback, however, on the feasibility of using Processing to make a roguelike. I like the ability of being able to tell Processing, "draw a square," and then it does and I can see it and mess with it.