Hi, been sometime since I posted here...

Okay strait to the point:

I'm having trouble getting my head around coordination system for a game. So lemmy explain a example;

I use panda3d which uses python, ofc i'm programming in python.
So the question. I want to create a coordination system for a game, which will take inputs from the PC(player) and then send the "space ship" to that direction, ofc not instant it will fly there over time...

Okay this all will take place in space as noted that we are flying around in a space ship. Now I don't know where to start.

I have to make an "invisible grid" which has blocks like sectors. Each with there own number or name or w/e. and this will be on x, y ofc.

Now the other thing is i thought I would put the Sun in the center, imagine our solar-system and the square will cover the whole "space" until about pluto so in your head see the grid. where the sun is in the middle. Now i need to init this thing (array/list/dict) and keep it safe, because later i'll have to add a checker which gives a false when the PC tries to enter random numbers. Meaning inside the space(and the grid) there will be a main story section like a tunnle which the player could only enter if he/she owns the data(the correct coords) other wise if they enter random number which happens to be inside that section the game would give some error in gui like "its out of bounds or w/e". but this doesn't stop them from actually fly to a random location.

So to come back after ^that... I'll say that I need to design a grid so that the player could enter "coords" and then move to that location. So how would I even start with this?

Thanks in advance

Okay so I figured out a way todo it, this is a basic sample I guess. I'll work from this and add the extras.

Note: Some calls in this code rely on the Panda3d Engine...

Sorry about the code for not being commented good. :)

So I guess this thread is finished...

Edit: Forgot to add the image: Click Here

# Coordination system

For making random sector names, will add this before or after the 2 or more important char
in the pos_dict.

''.join(random.choice('0123456789ABCDEF') for i in range(5))


from pandac.PandaModules import loadPrcFileData
    window-title Grid
    fullscreen 0
    win-size 1024 768
    cursor-hidden 0
    sync-video 0
    show-frame-rate-meter 1

from direct.showbase.ShowBase import ShowBase
from direct.gui.OnscreenText  import OnscreenText
from direct.filter.CommonFilters import CommonFilters
from pandac.PandaModules      import *
import random
import sys

class Space(ShowBase):

    def __init__(self):

        #self.filters = CommonFilters(base.win, base.cam)
        #self.filters.setBloom(blend=(0.33, 0.33, 0.33,0), desat=0.0, intensity=1, size="large")

    def genLabelText(self, text, i):
        return OnscreenText(text = text, pos = (-1.3, .95-.05*i), fg=(1,1,1,1),
                                align = TextNode.ALeft, scale = .05, mayChange = 1)

    def createDots(self):
        format = GeomVertexFormat.getV3()
        vdata = GeomVertexData('points', format, Geom.UHStatic)

        vertex = GeomVertexWriter(vdata, 'vertex')

        counter = 0
        pos_dict = {}
        for i in xrange(300000):
            x = random() * 255
            y = random() * 255
            z = random() * 63
            if random() < image.getBright(int(x), int(y)):
                if random() < image2.getBright(int(x), int(z)):
                    if random() < image2.getBright(int(y), int(z)):

                        vertex.addData3f(x, y, z - 32)
        # X, Y

        grid_x = 11
        grid_y = 11

        for count_y in range(grid_y):

            for count_x in range(grid_x):

                pos_dict["Block"+str(counter)] = (count_x, count_y)


        print pos_dict['Block0'], pos_dict['Block60']

        # Some testing show the spheres
        # Small sphere
        testModel = loader.loadModel("planet_sphere")
        testModel.setPos(pos_dict['Block0'][0], pos_dict['Block0'][1], 0)
        print testModel.getPos()

        # bigger sphere
        test2 = loader.loadModel("planet_sphere")
        test2.setPos(pos_dict['Block60'][0], pos_dict['Block60'][1], 0)
        print test2.getPos()

        for entry in pos_dict:
            print entry

        # ////

        prim = GeomPoints(Geom.UHStatic)

        geom = Geom(vdata)

        node = GeomNode('gnode')


        nodePath = render.attachNewNode(node)

        #self.info = self.genLabelText("Info: ",1)
        #self.pointinfo = self.genLabelText("Points: "+str(counter), 2)

        #print "The number of bytes being used: " +str(prim.getNumBytes())+"Bytes"

Main = Space()
Generous for you sharing!
This article has been dead for over six months. Start a new discussion instead.