specsdude
Posts: 52
Joined: Sat Jan 21, 2012 2:15 pm
Location: In a small English village, far from the eyes of Mordor

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Fri Jun 08, 2012 3:37 pm

doctorwho wrote:I don't know anything about this kind of stuff so I was wondering if the terrain is generated on the fly or if there is a dedicated 3d terrain model that is already in the game. If it is generated on the fly where are the variables (average variance in terrain height and such) kept? It seems that it might be viable to start making simple python scripts to generate worlds now.
I was also wondering if multiple characters can meet in virtual worlds yet?
About the terrain, it's mentioned above that there is actually a terrain mesh which is part of the scene. You're able to edit this in the blend file, then exporting it to.. egg? bam? can't remember. It's all documented on the wiki.

I'm sure that multiple characters CAN meet up... I'm not sure how you connect to a server yet though. I'll find out once I get the server and client working. But Pete will know.

Pete?
Arise! Arise, riders of Théoden! Spears shall be shaken, shields shall be splintered - a sword day, a red day, ere the sun rises! Ride now! Ride now! Ride! Ride to ruin, and the world's ending! Forth Éorlingas!

doctorwho
Posts: 11
Joined: Sat Mar 03, 2012 11:32 pm

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Fri Jun 08, 2012 4:16 pm

I looked it over on the wiki and it seems that you need a "heightmap (a monochrome bitmap where brightness corresponds to the terrain height at a certain location)" which python can definitely generate. So If we had a script that generated these maps based on parameters such as average height then we could generate new terrain easily.

PeteX
Posts: 50
Joined: Tue Apr 03, 2012 11:36 am
Contact: Website

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Fri Jun 08, 2012 7:05 pm

I've just created a forum on the friendlyfruit.org site, which should be easier to use than this one thread! :D

I've taken the latest posts from here, and replied to them in the appropriate part of the forum. If you go there and look around, you should find an answer to anything you were asking about here. If not then I've probably missed it; please start a new thread and I'll pick it up as soon as I can.

If you have any problems with the forum, please let me know. I'll have very limited time until next week, though, so please be patient.

ikesmasher
Posts: 25
Joined: Tue May 29, 2012 2:50 am

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sun Jun 10, 2012 9:51 pm

Heightmaps work, just need to be VERY, VERY high res for a open world terrain.

phrasz
Posts: 46
Joined: Fri Jun 01, 2012 4:13 am

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sun Jun 10, 2012 11:42 pm

Personally I'd code for the pi and then go cross platform...

PeteX
Posts: 50
Joined: Tue Apr 03, 2012 11:36 am
Contact: Website

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Tue Jun 12, 2012 3:20 pm

The current heightmap is 513x513 (Panda likes heightmaps to be a power of two plus one). It's meant to represent a 1km square, so the heights are stored with a resolution of one sample every two metres approximately. It seems to work okay; you can't see obvious breaks in the landscape.

Incidentally, in the process of doing this, I realised how unrealistic games are about size. World of Warcraft appears to have a continent-sized map, but I decided to measure it. It turns out that you can run across one of the regions in about eight minutes, so they're only about a mile across. I decided to make the demo FriendlyFruit map a kilometre across, so we're in the same ballpark but not being quite so ambitious.
Personally I'd code for the pi and then go cross platform...
That would probably be the best option, but I don't actually have my Pi yet, so it's not practical. It would also be nice if the hardware floating point issues got sorted out before we attempt this, because it will make a big difference to the performance of this type of program.

doctorwho
Posts: 11
Joined: Sat Mar 03, 2012 11:32 pm

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Fri Jun 15, 2012 4:59 pm

Everything below is about the first and very messy copy of my program
I've done some work with the height maps with perlin noise ( a algorithm used to generate realistic looking landscapes, clouds , and other textures).
I actual got the code in the form of pseudocode from this guys website: http://freespace.virgin.net/hugo.elias ... perlin.htm , it took me about 3 minutes to convert this to python with hardly any changes( although I had to add a random number generator for the base noise maker). From there I wrote something to put together the images. The image making code uses PIL(Python Imaging Library) but because it is written in python 3.2 I had to use a unofficial PIL version, http://www.lfd.uci.edu/~gohlke/pythonlibs/
The PerlinNoise_2D() function accepts the x and y values of the pixel and the persistence and number of octaves too. I have found that 10 for both the persistence and number of octaves works well. pic() will return a fully made perlin image.
I have not gotten a chance to test this in friendly fruit do to issues with my ubuntu computer. So I would appreciate it if somebody tested this or found other good values for the persistence and number of octaves. Beware, the code I currently have is really ugly and messy and I will get around to fixing it soon. Below is the code( use newimg() to generate a blank image that you can then use in the pic() function):

Code: Select all

def newimg(size):
    return (PIL.Image.new( 'RGB', (size,size), (225,225,225))) # create a new black image
    return
     # create the pixel map
points={}
def Noise(x,y):
    if not str([x,y]) in points:
        points[str([x,y])]=random.random()
    return(points[str([x,y])])
        
def SmoothNoise_1(x, y):
    corners = ( Noise(x-1, y-1)+Noise(x+1, y-1)+Noise(x-1, y+1)+Noise(x+1, y+1) ) / 16
    sides   = ( Noise(x-1, y)  +Noise(x+1, y)  +Noise(x, y-1)  +Noise(x, y+1) ) /  8
    center  =  Noise(x, y) / 4
    return corners + sides + center

def InterpolatedNoise_1(x, y):

    integer_X    = int(x)
    fractional_X = x - integer_X

    integer_Y    = int(y)
    fractional_Y = y - integer_Y

    v1 = SmoothNoise_1(integer_X,     integer_Y)
    v2 = SmoothNoise_1(integer_X + 1, integer_Y)
    v3 = SmoothNoise_1(integer_X,     integer_Y + 1)
    v4 = SmoothNoise_1(integer_X + 1, integer_Y + 1)

    i1 = Interpolate(v1 , v2 , fractional_X)
    i2 = Interpolate(v3 , v4 , fractional_X)

    return Interpolate(i1 , i2 , fractional_Y)
def Interpolate(a, b, x):
    return  a*(1-x) + b*x


def PerlinNoise_2D(x, y,p,n):
   #p is persitance and n i number of octaves
    total = 0.0
    n = n - 1

    for i in range(0,n+1):

        frequency = 2*i
        amplitude = p*i

        total = total + InterpolatedNoise_1(x * frequency, y * frequency) * amplitude
    points={}
    return total
def pic(img,p,n,height,length):
    pixels = img.load()
    for i in range(length):
        for j in range(height):
            newcolor=int(PerlinNoise_2D(i, j,p,n))
            pixels[i,j] = (newcolor,newcolor,newcolor)
    return(img)
The image below is tiny but it is a fair sample of what my program can do.
Image

PeteX
Posts: 50
Joined: Tue Apr 03, 2012 11:36 am
Contact: Website

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Mon Jun 18, 2012 11:22 pm

That looks interesting, I'll give it a go and see what the generated terrain looks like from within FriendlyFruit. (At the moment I'm working on getting FriendlyFruit working in Windows, though, and it probably makes sense for me to finish that first. I don't want to get pulled in too many different directions.)

How are you intending that this should be used? Do you want to create entire games algorithmically, with your program creating terrain plus objects, monsters, quests and so on? If you're not doing that, incidentally, there is a small snag. At the moment you place objects (like the cathedral and trees) using Blender. If the terrain has been generated directly as a heightmap and doesn't exist in Blender, this means you won't be able to see the terrain when you are placing objects. This will make it difficult to avoid placing objects underground or floating in the air.

One option is to turn your heightmap into a Blender mesh. I think that's possible if you create a texture with your heightmap on it, then set it as a displace map. That will cause the heightmap to displace the nodes of a mesh up or down depending on colour, which is exactly what you want.

doctorwho
Posts: 11
Joined: Sat Mar 03, 2012 11:32 pm

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Thu Jun 21, 2012 6:52 pm

I'm thinking that I might make it so you can create images with red and green values representing a range in which the ground height has to be. This way you could make one of these and use it to generate areas where you would know what the ground height would be. You could then place creatures without fear of them floating or being buried.

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sun Jul 15, 2012 3:02 am

Hi Pete, SN, and everyone else,

Has all of the activity moved over to the FriendlyFruit.org?

I've had my head down working on getting Panda3D running at a minimal level on the Pi and the memory limitations are just really hard using the standard Pi Debian releases (currently on the Wheezy beta, which is a big improvement. I will be trying Raspbian since it has hardware floating-point compiled in, which speeds things up anywhere from about 30% to tens of times faster (with the possibility of hundreds of times for a few things feasible in the not-too-distant future). However, RISCOS is now in beta and it only requires tens of MBs ... for the entire OS in files! That may be the stripped-down baseline I really need, and I will be trying it out tonight (Saturday, U.S. West Coast time).

I'm trying to have some simple 3-D demos running for the Raspberry Jam at the Computer History Museum in Silicon Valley on Saturday, July 21st, that I'm also coordinating (I really need to decide what I want to do if I grow up! :D ).

More to Come tomorrow after I've had a chance to get back on the Pi boards (I have mine, a second that's a loaner, and a third that's a loaner arriving Monday!). That's allowing me to test my ideas for network-sharing Pi-finity! game elements between Pi boards, such as world definitions, models, character actions/interactions, status of elements, earned/captured/paid elements, etc.

Now I'm going to go check in at the FriendlyFruit.org forum.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!


timeisaparallax
Posts: 17
Joined: Thu Jan 10, 2013 3:42 am
Location: Chicago

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sat Feb 09, 2013 2:43 am

So what's the state of the project at this point? I'd be interested to help out where I can if anyone is still actively in development .


- B

ikesmasher
Posts: 25
Joined: Tue May 29, 2012 2:50 am

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sun Feb 17, 2013 5:53 pm

Still havent gotten around to getting a RasPi, but am interested to see if anyone has been working on this since july.

jjkoehorst
Posts: 24
Joined: Mon Apr 16, 2012 8:16 am

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sun May 19, 2013 3:44 pm

I accidentally deleted my previous post... but I was shocked to see what has happened or not has happened with friendlyfruit. I was in it for a short moment and unfortunately was out of it for a while and now I was curious to the progress of it and found out it is near death?

I was loving the idea of a distributed mmo game in an eve setting with complete freedom. So I was curious to whom has the skills and interest to pursue this idea?

User avatar
Werewolf6851
Posts: 11
Joined: Sat Dec 08, 2012 6:43 am
Location: Tomah, Wisconsin

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Thu Sep 05, 2013 7:33 am

Still reading thru this interesting thread. But it if still going, might also think about audio candy (music/sounds/voices) Non-programers could add these artistic touches.

Wolf

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Fri Sep 06, 2013 5:01 am

To quote the guy tossed on the cart during the Black Plague skit in "Monty Python and the Holy Grail", "I'm not dead yet!" I'm building on the Pi3D library (https://github.com/tipam/pi3d) so that people learning Python can learn from the source code and quickly get up-to-speed using the Pi's very capable GPU to create and manipulate 3-D graphics. The Pi3D team has also been developing echomesh, which allows Pi boards to communicate over a mesh network whenever they discover each other in proximity, although I've already managed to get a minimal peer-to-peer capability for sharing data working.

To get an idea what Pi-finity! will look like, check out the Pi3D demos such as Starfield.py for interstellar travel, Earth.py for interplanetary navigation, and DogFight.py for the surface-level navigation (either on the surface or in proximity when in the air). The potential for structures can be seen in BuckfastAbbey.py and vegetation-dominated terrain can be seen in ForestWalk.py. Pi3D supports import of arbitrary models from files, so it will be easy for artistic users to create entities for populating Pi-finity! worlds and space itself. I'm working on a galactic 3-D model because we've already been able to create hundreds of thousands of stars from OpenGL ES Point() objects that make a galactic view eminently feasible - it's really impressive zipping around a 3-D spiral galaxy on a lark, and shows what the Pi's GPU can really do.

Pi3D has undergone some extremely substantial upgrades and improvements over the past year-and-a-half, and barely resembles what was available at the start. The code now has documentation auto-generated, although it still requires a lot more descriptive text to help users new to 3-D graphics, as the current documentation assumes a good deal of familiarity with OpenGL ES and Python.

I hope to have at least a canned navigation demo showing movement at the galactic, to interstellar, to interplanetary, to planetary surface levels working by October. It all depends on my teaching load as the new academic year is starting, and I'm working on other Pi projects, including a minimal Arduino Uno that will plug directly into the GPIO port, an adapted version of the Borderless Electronics $9 Arduino Leonardo clone that will plug into the GPIO port, as well as Raspberry Jams in Northern California, Monterey Bay Aquarium animal care and visitor guide volunteer work, and volunteer docent work at the Computer History Museum when not doing any of the above. I just can't decide what I want to do if I grow up! :lol:
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Fri Sep 06, 2013 10:09 am

Jim Manley wrote:As the evidence keeps mounting that yes, Virginia, there really are 10,000 R-Pi boards Out There and we can now increasingly hope that hundreds of thousands more will be delivered over the next few months. As this growing reality has started to sink in, I"ve begun thinking about some very cool things we could all do with each of our boards that would nicely demonstrate its many capabilities, encourage everyone with a board to participate and learn how to work cooperatively on a large computing project, and establish a real community of users that can bring us all closer together.

It soon occurred to me that one approach might be to establish an R-Pi massively multiplayer online role-playing game (MMORPG), since you can"t get much more massively multiplayer than hundreds of thousands of rabid R-Pi fans looking to share their newfound infatuation.

Eben and the team have demonstrated Quake 3 running on a prototype board, but, it had issues that I don"t think have been resolved, yet (some excuse about pesky prospective customers with torches and pitchforks marching on the castle needing to have hot oil poured on them ). However, even after the client is debugged, establishing and supporting Quake 3 servers for hundreds of thousands of players probably isn"t something very many are willing to do on a volunteer basis and donating resources.

So, after a few more moments of thinking, it occurred to me that it would be really cool if we developed one, or more, MMORPGs unique to the R-Pi community that could only be played on R-Pi systems. Since the preponderance of comments suggests that there is a lot of experience with Python, and that contributors without much software development experience might be able to come up-to-speed the fastest using Python, which does have extensive libraries available that should provide all of the functionality needed to build games (I seem to recall that some work may need to be done for full 3-D graphics support via the GPU).

It"s been quite a while since I"ve done any game development, but, I do have pretty extensive 3-D graphics and network-distributed computing experience, specifically in modeling and simulation and virtual reality for application areas like military command and control, communications, intelligence, and computing. I"m assuming that there is a fairly extensive open-source game code base we could draw upon from a variety of places, and I"m sure there are plenty of experts here that can help get things organized fairly quickly.

I haven"t thought much about what kind of game would be both popular and appropriate for all ages, given that the focus of the community is supposed to be educational. So, a first-person shooter is probably out, unless the weapons operated non-violently (think ammunition like Silly String, whoopie cushions, popping balloons, bubble gum, etc.). A purely fantasy-oriented game featuring unicorns and rainbows might not be as popular as other genres, although something that combines humor/silliness with more traditional features might turn out to be very popular. Perhaps a melding or updating of classical early computing games with modern graphics capabilities and techniques would be the ultimate tribute across the years. Think Breakout/Brickout in immersive 3-D, Grand Theft Auto with Zelda characters and behaviors, Donky Kong in virtual reality, Super Mario Brothers as a space quest, a Zork adventure game with hundreds of thousands of players, etc.

I haven"t looked closely to see if an appropriate game engine already exists, but, I have a gut feeling that some sort of peer-to-peer means of sharing parts of the game landscape among players active in given virtual geographic areas so that centralized servers won"t be necessary might be possible. I do understand that maintaining consistency of shared data across thousands of systems that could have transient connectivity via peer-to-peer technology could be problematic, but, I"m aware that research has been done to address this kind of problem, if it hasn"t already been resolved in open-source code.

3-D graphics will be used in order to show off the capabilities of the GPU and 1080p HDMI output. It"s not clear whether there is support for more than stereo digital sound via the HDMI port, but, if there is, it should be exploited to the maximum extent possible.

As you may have gathered by now, this is just at the nascent brain fart stage, and there is a huge number of details that need to be worked out. However, I don"t want to focus in on details, yet, and would rather hear as many wild and crazy possibilities voiced as part of a free-association mental exercise. Once we"ve laid out what we all can come up with, then we can start winnowing things down to what"s reasonably feasible and most popular to the largest number of people, across all demographics by age, gender, educational level, economic status, etc.

The key principles are that we would be doing this for fun and to help R-Pi users learn how they can develop software that satisfies common goals shared by a large number of people. Anyone who just wants to take pot-shots, cast aspersions, or otherwise non-constructively criticize what"s being done is hereby being put on notice that such behavior is not going to be tolerated. If a criticism is made, a positive suggestion to resolve the perceived problem must be provided and, if it"s not accepted by the group, so be it. We will follow the monkey owner principle – if you remark on the monkey someone else is carrying, then you take responsibility for the ongoing care and feeding of that monkey.

I"ll put together something with a lot more structure over the next few days, and in the meantime, I"d like to just hear what ideas others have about such a project. I"m not interested so much in just yay/nay responses, but, rather what you think about the factors I identified, plus any others you might think are important. I haven"t listed all of the issues that will need to be addressed, so, this will give others the opportunity to share what they can contribute toward the project"s goals.

Thanks!
THERE MUST BE MORE THAN 10,000! PyORPG is another MMORPG, but, actually, if you got a cluster of Pi's, you could probably play the settlers online too!
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

jjkoehorst
Posts: 24
Joined: Mon Apr 16, 2012 8:16 am

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Fri Dec 27, 2013 8:44 am

Jim Manley wrote:
I hope to have at least a canned navigation demo showing movement at the galactic, to interstellar, to interplanetary, to planetary surface levels working by October. It all depends on my teaching load as the new academic year is starting, and I'm working on other Pi projects, including a minimal Arduino Uno that will plug directly into the GPIO port, an adapted version of the Borderless Electronics $9 Arduino Leonardo clone that will plug into the GPIO port, as well as Raspberry Jams in Northern California, Monterey Bay Aquarium animal care and visitor guide volunteer work, and volunteer docent work at the Computer History Museum when not doing any of the above. I just can't decide what I want to do if I grow up! :lol:
I am really curious to the progress you made to the galactic interstellar/planetary movement. I think a free programmable space game [2d/3d] would be appealing to most people. That you can learn to code your own droids to do things for you or program AI etc. I'll try to stay in touch as much as possible from now on as things tend to get a bit slow around here.

To edit my post a bit, for more attraction of new people space might not be the only way to do things. It might be nice to set up planetary regions where people can build, tinker, mine, develop new tools. As for example food can't really be found in the emptiness of space although farm stations might do the trick. And please don't think about levelling in the classical way...

To finalize, I need to find a way to get pi3d running on a macbook pro. I have a virtual machine set up but libEGL fails to authenticate so far.

User avatar
paddyg
Posts: 2395
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Tue Jan 07, 2014 1:55 pm

@jjkoehorst
did you get anywhere with pi3d on the mac? I don't have one to hand but if you let me know the issues I might be able to remember the kinds of things I had to figure out for general linux

One thing I would have thought would mess things up is that we only really do anything with 'linux' and 'darwin' in pi3d/constants/__init__.py
If you run a python terminal and do
>>> import platform
>>> platform.system()
what do you get?
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

Thediehardtrilogy
Posts: 19
Joined: Thu Oct 10, 2013 9:54 pm

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sat Jan 11, 2014 4:23 am

If a MMORPG is on the pi, I would be so freaking happy!!!

jjkoehorst
Posts: 24
Joined: Mon Apr 16, 2012 8:16 am

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sun Jan 12, 2014 10:35 am

I think its a video card / driver issue as with that command i get Linux. But it works alright on a pi. Currently trying to create a spaceship with freelancer like movements, e.g. mouse look.

Github: https://github.com/jjkoehorst/spacepi

User avatar
paddyg
Posts: 2395
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Sun Jan 12, 2014 4:35 pm

I've come across video card issues before with EGL (not personally but seen them mentioned) Often fixed by loading latest drivers, good luck with that and let me know how you get on. My wife has a mac but I am STRICTLY forbidden from fiddling with it!

I'm not entirely sure what you intend by the mouse look but after a quick 'flight' I would suggest the following:
don't mix the mouse pointer locations (which are 2D screen pixel related) with the 'real world' (real space) x, y, z positions. This might happen to work in some locations but generally won't.
The point_at needs to point at a real 3D location, by fixing z at 1000 it will look backwards once you move further than that! I think I would make the camera generally point at the spacecraft but maybe have an option that toggles between view and steer (I did something like this with the DogFight demo).
I would do 'proper physics' for steering i.e. apply an up, down, left, right thruster depending on the distance of the mouse pointer from the centre of the screen and have (x,y,z), (dx,dy,dz), (d2x,d2y,d2z) vectors. I would add these as attributes to the ship object rather than having a floating variable i.e. ship.location[0], ship.velocity[0] (NB not speed which doesn't work in space where there's no traction) you also need rotational vectors and their derivatives which you will need to cunningly control also with the mouse position!!
Use a 2D camera for the text. i.e. see attached.
Also I tidied up the MergeShape so you can do
ship.add(ship_core, 0.0, 1.6)
ship.add(ship_ring, 0.0, 1.5)
and it will extract the relevant Buffer list

Code: Select all

#!/usr/bin/python
from __future__ import absolute_import, division, print_function, unicode_literals
""" Use of points by using set_point_size() to a non-zero value. There is
no attempt to 'tile' the points to give continuous motion
"""
import demo
import pi3d,sys

#Spaceship class implemented in the future...

def movement_player(k,ship,mx,my,ship_speed):
  if k==112:
    pi3d.screenshot("earth1.jpg")
  elif k==27:
    mykeys.close()
    DISPLAY.stop()
    DISPLAY.destroy()
    #Not sure if this is a nice way to stop
    sys.exit()
  #Need to create a space movement ish.
  #When W is pressed and mouse is at far right top, it needs to turn fast...
  #When W is pressed and mouse is close by... it needs to turn sloooowly
  elif k == 119: #key, w
    #Detect distance from mouse to ship # or center of screen???
    #print ('\t'.join([str(mx),str(my),'\n']))
    #Move ship
    #Speed is increased by 0.1 per tick when pressed
    ship_speed[0] += 0.1
    #bend_speed_X = (mx / 50 )
    #bend_speed_Y = (my / 50 )
    #Forward
    #ship.positionZ(ship.z() + 0.5)
    #ship.positionX(ship.x() + bend_speed_X)
    #ship.positionY(ship.y() + bend_speed_Y)
  elif k == 115: #key, s #Moving backwards
    ship_speed[0] -= 0.1
  elif k == 97: #key, a #Flip shift to left or right... camera movement not yet fixed
    ship.positionX(ship.x() - 0.5)
    #Maybe for Q and E
    #ship.rotateIncZ(0.5)
  elif k == 32: #Space bar brings ship to halt
    if ship_speed[0] > 0.5:
      ship_speed[0] -= 0.3
    elif ship_speed[0] < -0.5:
      ship_speed[0] += 0.3
    else:
      ship_speed[0] = 0
      
  elif k == 100: #key, d
    ship.positionX(ship.x() + 0.5)
    #Maybe for Q and E
    #ship.rotateIncZ(-0.5)
  ship.positionZ(ship.z() + ship_speed[0])
  #MAX X Y Z
  #Zfwd = 300ms
  #Zrev = 100ms
  #Y = bend speed?
  #Per tick it should increment speed, this should be shown on screen...
  return ship, ship_speed


def camera_postioning(CAMERA,mx,my,k):
  CAMERA.reset()
  CAMERA.position((ship.x() , ship.y(), ship.z()-20))
  #Look to where the mouse points at
  #Somehow messes up camera positioning. 
  CAMERA.point_at([mx,my,1000])
  if k == 97: #key, a
    CAMERA.rotateZ(0.5)
  elif k == 100: #key, d
    CAMERA.rotateZ(-0.5)
  return CAMERA

def mouse_look(mymouse,ship):
  #From position of object...
  mx, my = mymouse.position()
  #SET MAX POS so you cannot look 360*
  TOPX = ship.x() + 200
  BOTTOMX = ship.x() - 200
  TOPY = ship.y() + 200
  BOTTOMY = ship.y() - 200
  if mx > TOPX:
    mx = TOPX
  elif mx < BOTTOMX:
    mx = BOTTOMX
  if my > TOPY:
    my = TOPY
  elif my < BOTTOMY:
    my = BOTTOMY
  return mx, my
    
#from six.moves import xrange

# Setup display and initialise pi3d in full screen mode
DISPLAY = pi3d.Display.create()
DISPLAY.set_background(0,0,0,1)      # r,g,b,alpha
# Camera initialization
CAMERA = pi3d.Camera()
CAMERA2D = pi3d.Camera(is_3d=False)

shader = pi3d.Shader("uv_reflect")
flatsh = pi3d.Shader("uv_flat")
#matsh = pi3d.Shader("mat_flat")

earthimg = pi3d.Texture("textures/world_map.jpg")
metalimg = pi3d.Texture("textures/metalhull.jpg")
# Load shapes
earthsphere = pi3d.Sphere(radius=5, slices=24, sides=24,
                  name="earth", x=10, y=-5, z=180, camera=CAMERA)
earthsphere.set_draw_details(shader, [earthimg])

#create ship
metalimg = pi3d.Texture("textures/metalhull.jpg")
ship_core= pi3d.Sphere(radius=1.0)
ship_ring = pi3d.Cylinder(radius=2.0, height=0.1, sides=12)
ship = pi3d.MergeShape(camera=CAMERA)
ship.add(ship_core, 0.0, 1.6)
ship.add(ship_ring, 0.0, 1.5)
ship.set_draw_details(shader, [metalimg, metalimg], 0.0, 0.5)
ship.position(1, 1, 1)
ship.speed = [0,0] #Fwd/Rev Left/Right

#ship = pi3d.Sphere(radius=2, slices=24, sides=24,
#                  name="ship", x=0, y=0, z=0)
#ship.set_draw_details(shader, [metalimg])
#myplane = pi3d.Plane(w=500, h=500, name="stars", z=400)
#myplane.set_draw_details(flatsh, [starsimg])

"""create the shape to hold the points. This could be encapsulated in its
own class to generate the required distribution and shield the user from
having to explicitly create the Buffer object and set the Shape.buf list
"""
verts = []

# Fetch key presses
mykeys = pi3d.Keyboard()
mymouse = pi3d.Mouse(restrict=False)
mymouse.start()

# Ship speed hud and more in the future
arialFont = pi3d.Font("fonts/FreeMonoBoldOblique.ttf", (221,0,170,255))   #load ttf font and set the font colour to 'raspberry'

# Display scene
#Game loop
while DISPLAY.loop_running():
  mx, my = mouse_look(mymouse,ship)
  k = mykeys.read()
  CAMERA = camera_postioning(CAMERA,mx,my,k)
  #To obtain mouse position for looking at...
  
  ship.draw()
  ship.rotateIncY(0.1)
  earthsphere.rotateIncY(0.1)
  earthsphere.positionZ(earthsphere.z() - 0.0001)
  earthsphere.draw()
  
  #Set ship in motion, and if in motion keep moving it! #Its space after all
  ship,ship.speed = movement_player(k,ship,mx,my,ship.speed)
  #Speed indicator
  speedhub = pi3d.String(font=arialFont, string='Speed: {}'.format(ship.speed[0]),
              x=-DISPLAY.width/2.0 + 50, y=DISPLAY.height/2.0 - 50, is_3d=False, 
              camera=CAMERA2D, justify="L")
  speedhub.set_shader(flatsh)
  speedhub.draw()
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Wed Jan 22, 2014 1:41 am

jjkoehorst wrote:I am really curious to the progress you made to the galactic interstellar/planetary movement. I think a free programmable space game [2d/3d] would be appealing to most people. That you can learn to code your own droids to do things for you or program AI etc. I'll try to stay in touch as much as possible from now on as things tend to get a bit slow around here.

To edit my post a bit, for more attraction of new people space might not be the only way to do things. It might be nice to set up planetary regions where people can build, tinker, mine, develop new tools. As for example food can't really be found in the emptiness of space although farm stations might do the trick. And please don't think about levelling in the classical way...
I'm chasing a rapidly-changing Pi3D infrastructure in order to get things done in Pi-finity!, but that's been a good thing as the changes are great improvements (well, when the developers don't inadvertently splatter the GitHub repository with an occasional goof - been there, done that, got a closet full of T-shirts! :lol: ). So, progress has continued to be slower than desired due to that and real-world distractions.

Those who have been reading my verbose blatherings on this subject may recall that space was just one of the intended scenario levels and that surfaces of planets, natural satellites (i.e., moons), asteroids, and comets (as the recent wake-up of the Rosetta spacecraft reminds us) can all serve as scenario locations. There's no reason why game play can't occur within a very localized area such as in a city, on an urban block, or even within buildings, as the Pi3D examples nicely demonstrate (e.g., BuckfastAbbey.py, MarsStation.py, and ForestWalk.py). Things can get complicated if you're trying to render models with articulations such as humanoids (e.g., people or robots that resemble them) doing even seemingly simple things like walking. Modeling skin and, for the real masochists, hair, is much tougher, so everyone wearing space suits with dark-tinted visors can simplify the processing required.

My goal is to provide not just a set of APIs, but a framework that others can expand by hanging their work on it. I'm trying to make it so it's not so complicated that it would slow the Pi to a crawl doing model/camera movement calculations and view rendering, i.e., it makes maximum use of the GPU and minimum use of the ARM CPU and doesn't consume too many gobs of RAM. Adapting existing 3D game engines has been extremely difficult because they assume that high clock speed x86 CPUs, high-end GPUs, and large gobs of RAM are available, and none of the engines that met most of my criteria were implemented in Python which is a goal of this project since that's what Pi3D is implemented in and it's the preferred language for the Foundation's education efforts.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

User avatar
paddyg
Posts: 2395
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Wed Jan 22, 2014 9:31 am

guilty as charged, more haste = less speed.
inadvertently splatter the GitHub repository with an occasional goof
When you've got even the tiniest start of a project; put it up on github. The issues system is a good way of carving up jobs, discussing problems and finding ways round them. These seem reasonable chunks that could be worked on independently by contributing devs:
- Animating figures - would it be better to have a 2D sprite with front, back, three-quarters etc atlas?
- Loading scenery resources in background thread to make world (galaxy) continuous.
- Internet database holding scenery specifications, locations, 3d models, textures
- User interface to allow users to contribute scenery, vehicles, figures
- Algorithm to determine which bits of scenery should be loaded, i.e. restrict to 10 nearest? but has to be clever enough to load 10 nearest planets/stars when flying through space rather than 10 nearest trees on the nearest planet.
- Reading and writing player locations from and to internet server
PS not forgetting game play!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: R-Pi Massively Multiplayer Online Role-Playing Games (MM

Thu Jan 30, 2014 5:48 am

paddyg wrote:When you've got even the tiniest start of a project; put it up on github.
Hi Paddy!

I tried to stitch together a "vision thing", as former President George H.W. Bush (President 41, not 43) would call it, from some of the demos, but there's enough differences in how each is implemented that it's been painful, at the very least. The idea was to essentially create a canned "fly-through" from a deep-space level down to inside a structure. Since you deeply understand the issues involved, you're one of the few who has "gotten" what I'm trying to do (must be a genetic thing - I look forward to activities with those sexy femalesque (I sure hope!) aliens on the steamy science-fiction novel covers geeks working in dark rooms find so appealing :lol:). As you sagely noted, intelligent rendering only proximate elements to the camera's/player's location in 3-D space is key to keeping everything in one sock of RAM without putting a big hole in the sock.

Sharing of models, textures, etc., is one of the weakest things that I've observed of various 3-D visualization systems. Yes, you can exchange lower-level files in various formats such as wireframe models in DXF, textures in GIFs, etc., but there doesn't seem to be a widely-accepted way to exchange all of the components needed to render an object, particularly within a scene that itself is built from constituent components (SolidWorks seems popular ... as long as one is using SolidWorks, Blender seems like a candidate, but I'm not an expert with it, etc.,). It appears that everyone has their own floor in the Tower of Babel and each of them has a completely differently-shaped door that opens inward or outward haphazardly into a staircase that would make even Escher dizzy! Oh, I was looking for an elevator? HA-HA-HA-HA-HA-HA-HA-HA-HA!!! Hmmmm, an Escheresque 3-D world ... the rusty gears in my noggin are beginning to turn in fits and starts, making much smoke and noise! ;)

You're right, I really need to hang pieces Out There on GitHub and I'm working toward that. Maybe once I've taught my students how tools and libraries such as Python and Pi3D work, they can pick up the standard (as in what a standard-bearer in an army carries) from my arthritic hands as I lie on the Plain of .jars (fits history better than the Plain of .pycs :) ) and establish steady progress forward :roll:
paddyg wrote:PS not forgetting game play!
DOH! Game play? We don' need no steenkeen game play! :P
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

Return to “Gaming”