Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 30 Nov 2012
Offline Last Active Oct 20 2016 03:32 AM

#5288239 Simulating Human with Rigid Body Joints

Posted by on 22 April 2016 - 08:26 PM

It would probably be a lot more easy to just bake animations for walking, punching etc. rather than calculating all the torques necessary to do these types of things. The forces involved in just standing up are pretty complex, and you don't want to waste CPU time having your character just stand.

You can use physics simulation when the person is actually at the mercy of physics, like when he is dead, or thrown back or something. That is called rag doll physics, but most games don't bother simulating physics for ordinary tasks.

#5287940 How did you learn making games?

Posted by on 21 April 2016 - 04:34 AM

I learned game-making about 8 years ago, so I hope my perspective is usefull to you.

What was the language you used first?

At first, I used both python and scratch (about the same time).

How much time did it take to learn?

I wouldn't say I ever finished learning. I might have gotten a little bit better, but I still allways start on projects that are too hard for me. But in your scale, a reasonable mastery to understand the features, maybe 3 years for python, 1/2 years for scratch.

Did other people like your first game?

My first game that I "Published" was a horrible horrible snake game clone. My dad was the only person who would come close enough to play it, and I don't believe he enjoyed it very much. I did upload it to google code, but I probably shouldn't have.

Are you still making games?

I am balancing them among my many hobbies.

#5250655 Random Math Questions

Posted by on 04 September 2015 - 10:52 PM

Cos returns the X value associated with a angle, Sin the Y value. You multiply sin and cos by your radius for a circle with a radius other then 1. The code listed takes a random angle (random(0,360), splits it into a x and y value. (The sine and cosine), then multiples it by a random number to make the distance random.

#5242889 Quadratic equations trouble

Posted by on 26 July 2015 - 09:41 PM

You are gonna want to expand the (x-y)^2's in all the equations, you should have no problem solving the equations and then substituting them if you do that.

#5226040 Scrolling text area

Posted by on 28 April 2015 - 04:58 AM

By guess is that you will need to make a variable for the text, and then have setText and getText functions. I will make it easy for you:

public class MsgList : MonoBehaviour {
	private Vector2 scrollPosition;
        private String text;
	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {


	void OnGUI() {
		scrollPosition = GUILayout.BeginScrollView (scrollPosition, GUILayout.Width (200), GUILayout.Height (50));
		GUILayout.Label (text);
		GUILayout.EndScrollView ();
        public void setText(string Text){

Assuming this is C# (This looks like Unity, am I right?)


Now all you need to do from the player is, in unity, do something like FindObjectsOfType, and either call setText on it or send a message. Eventually, you will want a more complicated system that keeps strings in a cage while making sure each one is shown for enough time, and you might also want play a sound or visual effect.

#5214884 SpriteSheet Class won't correctly display transparent images

Posted by on 05 March 2015 - 10:10 PM

I don't think you can have a image with both alpha and color key. Your code should be:

        rect = pygame.Rect(rectangle)
        image = pygame.Surface(rect.size, pygame.SRCALPHA)
        image.blit(self.sheet, (0, 0), rect)
        return image

what this code does is first give the image a alpha channel by using the flag SRCALPHA. Then you are making sure it is fully transparent, since its black by default, and then write your image over it like you normally would.


The main important part is to decide whether you want to use the extra processing power and memory to use alpha mapped images, or just use color keys, that look worse. You are trying to do both, which doesn't really work.



I found the file you based this on on the pygame wiki. The only thing you changed was the convert_alpha. Now your sprite sheet has a alpha channel, but not your sprites. To get sprites with alpha, use SRCALPHA

#5212239 My First Game Concept

Posted by on 22 February 2015 - 04:52 AM

whats the game going to be about?

#5211655 Pygame Rect move help

Posted by on 19 February 2015 - 04:43 AM

I would recommend checking the type of the rect any time it is accessed within the code, with a description of where. So wherever you use it,


assert isinstance(player.Rect,pygame.Rect), "{filename, linenumber} \
 player.rect is not a rectangle"

the program will crash at the first point where the type is incorrect. If the uses are more then like a hundred, you can hack it a bit using attributes and stack traces.
If you find it is not a rect immediately, because you have a weird version of pygame, or thing are different in python 2.x, then you can just do:


the code seems a bit weird at the beginning, since you are storing the location in 2 ways: the position of the rect, and the point self.location. You probs made a mistake while syncing those.


ps. the attributes function is the most useless function I have ever seen. I hope it has some special function that I don't know about.

ps. sory if my answer is confusing

#5199085 Stuttering on game start - missed collisions

Posted by on 19 December 2014 - 06:27 AM

I didn't read your code, but the usual problem is that you are going so fast that you are above the object you are colliding with one frame, (So no collision) and below it the next, (So still no collision). The normal way to fix this is to collide using a polygon that includes all positions the object has been in in between the frames. Also, what units are you measuring gravity in? Pixels? A pixel does not necessary equal a meter, so its better to just set it to any value that looks realistic enough and works. (Unless you need it to be more accurate for some reason, are using a physics engine, or have a different good reason)


The stuttering could be caused if you are still trying to load data while the game loop is already running. It could have something to do with your event system to, I don't know about that one.

#5192247 Procedural Map Generation

Posted by on 11 November 2014 - 05:07 AM

Usually, the method is to first generate a few rooms, then connect them with passageways until they are all connected. The rooms can be in any place so that should be easy. For the passageways you will need to experiment with a few algorithms to find one that works. A lot I tried were either to slow or used to much memory, so the one I ended up with was based on just moving first the x then the y towards the target, and if you ran into a obstacle, only do X (or only do Y) until you are past it. This is probably not the best method, since it often fails to find a path, but its fast and avoids obstacles pretty well.

My program was in python, so I don't know if seeing my code would be helpful for you, if it is, just ask!

#5190887 Vertically scrolling underwater game, what to use as background?

Posted by on 03 November 2014 - 06:22 AM

bubles and rocks, and creatures, maybe you can have a wall on the sides that can move?

#5187300 Slow performance on A*

Posted by on 15 October 2014 - 09:40 PM

The first loop is to only grow my grid until  I have all the weights between the start point and the end point,
the second loop runs threw all the tiles to see if they have a adjacent tile with a value yet
the third loop runs threw all the adjacent tiles, and selects the smallest one to be the value of the tile. I also evaluate tiles that already have a value again for if a new route from the other direction has been generated.
This is what I understood from the wikipedia entry on A*, but I am not sure if I am doing it correctly. The main difference seems to be that the wikipeda formula checks for a straight line first, but I can't do that because there is allays a straight line, I just want it to avoid walls, but if there is no way to do that, it will just crash threw them. I also want it to be more likely to follow existing pathways part of the way instead of making new ones.
With my earlier simpler method, it would just make a straight line, right threw rooms and sometimes along walls, turning every wall piece into a door, witch looked very ugly.


that is 100*10000*4=4000000 (4M), that is a pretty big number, but every nesting seems to be necessary. This is also only the maximun number, usually it will reach its destination before 100 tries, or neer the edge, getadjacent will only return 3 values, but actually it will be a full 4M most of the time.

#5187113 Slow performance on A*

Posted by on 15 October 2014 - 02:55 AM

For my level generator, I need to connect my rooms with passageways. I don't want pasageways to run straight thew other rooms, or crash straight allong walls, turning a whole row into doors, wich looks ugly, so I decided to use a more complicated algorithm to find the path for the paths:

        weightsgrid=Grid([self.rowsize, len(self.data)/self.rowsize],-1)
        while weightsgrid[pointb]==-1 and tries<100:
            for coords in weightsgrid:
                if weightsgrid[coords]>=-1:
                    if weightsgrid[coords]!=-1:
                    for adj in getadjacent(coords):
                            if weightsgrid[adj]>0:
                                #print "Did SOmething"
                        except IndexError:
                            #Can forget about this error since we don't care about values outside the grid
                    if len(posible)>0:
        if not function:
        while walkposition!=tuple(pointa) and tries<len(self.data):
                             key=lambda x: weightsgrid[x] if weightsgrid[x]!=-1 else 8388608)
            except IndexError:
                print walkposition
            #print tries
        return l

note that the class that generates subclasses grid, so self is also a grid object. The function works mostly well, but takes 2 or 3 seconds to run (least is 0.1 second, most is 5 seconds) and since I need to run it 19-38 times each time I generate a level, it becomes kinda unacceptable. Since I am doing this to learn, in the future I might need to use a similar system to for enemy movement, so I want to know what I am doing wrong.
Just in case you need it, this is the rest of my generator function:

        print "0}GENERATING ROOMS"
        for i in range(numrooms):
            while not ok:
                for room2 in rooms:
                    if ((room[0]<room2[0]+room2[2]+3) and #room.right>room2.x and room.x<room2.right
                        (room2[0]<room[0]+room[2]+3) and
                        (room[1]<room2[1]+room2[3]+3) and
                        #print room,room2
                if not ok:
                    #print "tries: ",tries
                if tries>1000:
                    print "failed after",tries,"tries"
            if tries<=1000:
        print "Len(rooms)=",len(rooms)           
            #print [x,y,width,height,floormats]
        print "0}Bordering rooms!"
        for room in rooms:
            for i in range(room[0],room[0]+room[2]+2):
                for j in range(room[1],room[1]+room[3]+2):
                    while not ok:
                        if (i==room[0] or i==room[0]+room[2]+1 or #x position
                            j==room[1] or j==room[1]+room[3]+1):
        print "0}Connecting rooms!"
        for room1 in rooms:
            room2s=[random.choice(rooms) for i in range(timesperroom)]
            for room2 in room2s:
                if room1!=room2:
                    print "Running a*! ({0:0>2}/{1:>2}) time: {2}".format(timestried,totaltimes,datetime.datetime.now()-lasttime)

edit: I see people don't get my problem, so I am going to post a few screen shots to show what I mean:


these are my rooms, but I need to connect them. So I run A* and I get:


this is great, except that it takes 5 minutes to run!

#5153539 Quantity over quality in a game when it comes to art - thoughts?

Posted by on 14 May 2014 - 06:15 AM

Though the background is really nice on the first picture, I would also get a better font and think about where to place those numbers. The stars could also be better.

#5117056 How to render a 2D isometric world in Python/Pygame

Posted by on 15 December 2013 - 04:27 AM

The code I used for my game is like this:

import math,pygame
class Square(object):
    def __init__(self, image, gridpos,level=0):
        self.isopos=[int(i*16) for i in gridpos]
    def draw(self, surface):
    def update(self,*args): pass
    def recalculateRealpos(self):
    def __gt__(self, other):
        if math.ceil(self.realpos[1]/16.0)!=math.ceil(other.realpos[1]/16.0):
            return self.realpos[1]>other.realpos[1]
            return self.level>other.level
    def __lt__(self, other):
        if math.ceil(self.realpos[1]/16.0)!=math.ceil(other.realpos[1]/16.0):
            return self.realpos[1]<other.realpos[1]
            return self.level<other.level

All you need to do is sort your list of objects and it looks fine. The system also supports relative scrolling, though it got to slow for me with larger rooms. Note that my tile size here was 64*64 and you might need to switch up the numbers if you have different sizes or angles. You can download the source for my game if you want to see how it is used (see my signature)

I am not sure if this is what you are looking for, but I hope it helps.