Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Collaborators for Allegro Demo Game Competition?

This thread is locked; no one can reply to it. rss feed Print
Collaborators for Allegro Demo Game Competition?
Elias
Member #358
May 2000

Figured out why the Blender exported levels crashed.. need to have all triangles with clockwise vertices (and that after transformation of course :P), and they must have 3 vertices only, not 4 like with Blender.

Attached is the latest version of the exporter script, and a test level done with it (Opening the level2.blend file in blender, with soil.bmp and grass.bmp in the same directory, then exporting, should give level2.txt. Copy that over level.txt to see in-game.)

--
"Either help out or stop whining" - Evert

Thomas Harte
Member #33
April 2000
avatar

Quote:

I've been playing around with some music... do you like the 'feel' of the 30 second clip I've attached? If I end up making some music for this thing, I don't want it to suck, so give me an honest opinion.

I'm just doing a file grab at the minute, but I'll post when I've had a proper listen, probably tomorrow. Thanks!

Quote:

Figured out why the Blender exported levels crashed.. need to have all triangles with clockwise vertices (and that after transformation of course :P), and they must have 3 vertices only, not 4 like with Blender.

Apologies, I need to write a 'how the levels are interpreted' type thing very soon. There is probably at least one more fix I need to make before the game reliable imports non-'perfect' levels too - specifically to discard duplicate edges. I guess if an edge runs from vertex 0 to vertex 1 and another runs from 1 to 0, both can be ignored.

Anyway, latest source and so on is attached. Objects are in and working, as is the door. Please laugh heartily at the visual representation of that!

The most striking known issue is that if you return to the menu then continue game, all the objects in the level suddenly reappear. Size has ballooned due to the inclusion of 'endoflevel.wav'. I'm not yet sure why the appearance of the 'you've won' screen causes the sample to be stopped. Probably miran's code is doing this on purpose (?)

Elias
Member #358
May 2000

Hm, crashes here:

1(gdb) bt
2#0 0x080641fb in LoadObjectTypes (NewLev=0x8214560, radius=18) at Level.c:741
3#1 0x0806467c in LoadLevel (name=0x80f7508 "level.txt", radius=18) at Level.c:905
4#2 0x080602dd in LoadResources (Restart=-1) at Game.c:372
5#3 0x080605fe in GameInit () at Game.c:424
6#4 0x0805f43b in run () at framework.c:195
7#5 0x0805ea13 in main () at demo.c:9
8(gdb) frame 0
9#0 0x080641fb in LoadObjectTypes (NewLev=0x8214560, radius=18) at Level.c:741
10741 (*NewObjectPtr)->Radius = ((*NewObjectPtr)->Image->w > (*NewObjectPtr)->Image->h) ? (*NewObjectPtr)->Image->w : (*NewObjectPtr)->Image->h;
11(gdb) list
12736 {
13737 *NewObjectPtr = NewObjectType();
14738
15739 ExpectSymbol(SM_STRING);
16740 (*NewObjectPtr)->Image = ObtainBitmap(Symbol.Text);
17741 (*NewObjectPtr)->Radius = ((*NewObjectPtr)->Image->w > (*NewObjectPtr)->Image->h) ? (*NewObjectPtr)->Image->w : (*NewObjectPtr)->Image->h;
18742 (*NewObjectPtr)->Radius += radius;
19743
20744 ExpectSymbol(SM_COMMA);
21745 ExpectSymbol(SM_STRING);
22(gdb)

--
"Either help out or stop whining" - Evert

Trezker
Member #1,739
December 2001
avatar

I just downloaded the attached source and didn't find a makefile...
Tried making dev-c++ project and failed building it.

Thomas Harte
Member #33
April 2000
avatar

Quote:

Hm, crashes here:

It seems very likely that it is unable to find one of the bitmaps it is expecting to be in game.dat. Level.c is not properly checking level.txt for validity as it loads, explaining that. Validity checks are simple and to grow as I document that file.

Probably I've not included the latest datafiles in my distribution. Alas I'm not at my development machine now (I'm in the library of Gray's Inn, off Chancery Lane in the sunny city of London) so I can't check this out!

Quote:

I just downloaded the attached source and didn't find a makefile...

No, I'm using XCode and for obvious reasons not including my workspace. I'm really thick about makefiles and have assumed 'someone else' will fix it! It should just be a matter of compiling everything and linking it with Allegro though, so I can't imagine what is causing the problem you face. I'll see if I can get a makefile put together.

Quote:

I should have mentioned, Thomas - I fall through that vertical wall even when jumping to it from the opposite wall of the half-pipe; so I pass through it regardless of how I approach it. It's as if the edge isn't even there...

I thought about this on the train. I'd be surprised if this particular problem isn't fixed in the new code. What was probably happening was that my 'infinite line and bounding box' method for finite line intersection tests was failing due to rounding errors with a bounding box of zero width. The tests are all <= / >= so there is an exact value that would allow collisions to be detected but of course comparing floats to exact values to test equality (the combined effect of an >= and an <= on the same value) is very stupid.

I've added a half pixel error allowance to all bounding box checks so the problem should be gone!

Elias
Member #358
May 2000

I compiled here with gcc -o ademo *.c `allegro-config --libs`..

About the crash, I'll just wait until you can check if the datafiles are right.

And the fall-through problems were already fixed for me in the previous version, blender exported geometry works completely after i realized the necessary triangle definition constraints :)

That is, on sharp edges, the collision detection is wrong. Instead of:

  /\
 /  \
/ /\ \

it should do:

  __
 /  \
/ /\ \

Not that it matters at all, can just be careful in level design to not make spiky geometry.

--
"Either help out or stop whining" - Evert

Thomas Harte
Member #33
April 2000
avatar

Quote:

That is, on sharp edges, the collision detection is wrong. Instead of:

Ah, yes, I had figured out this would happen. It's a result of implementing collisions in the way platform games expect so that when a character is standing with just a pixel left on the edge of a platform he will not fall. It also conveniently simplifies the collision checking, which I anticipate being very thankful of when I move all that to Physics.cpp and clean/document it.

In the example above, if you were to insert a single unit horizontal edge at the peak you would get the example shown below. I have some ideas for fixes up my sleeves which involve detecting where such a line should be automatically inserted at runtime but otherwise don't affect a great deal. I'm thinking that if the distance from the geometry peak and the collisions peak is greater than a certain quantity (my instinct tells me half the diagonal of the character square but I can't justify that yet) then a tangent edge will be added. But I need to think a little harder about this.

EDIT: a moment's thought reveals that is probably the wrong solution to take. The question is: is the character found to be standing on an edge when they are not? So the test is - how far does an edge extend parallel to the plane beyond the geometric end of the triangle edge? Any distance greater than half the width of the character sprite should be spliced and a tangent edge to the joint should be placed between that and the other edge.

I'll make this adjustment when I get home, then throw some geometry at it and check for anything that shows this is the wrong approach to take.

I'm going to have fun commenting this code! I planned to write up the algorithm in a separate document then just comment the code to refer to paragraphs in the article. Is that acceptable?

Trezker
Member #1,739
December 2001
avatar

about_menu.c lines 22-29: error, initializer element is not constant o_O

Thomas Harte
Member #33
April 2000
avatar

Damn it! GoodBytes already mentioned that compiler error and I neglected to do a single thing about it! The element is 'allegro_id'. An easy fix but for now if you don't mind the 'about' box not displaying the current Allegro version just replace 'allegro_id' with anything you like, e.g. "Thomas Harte often forgets to fix problems he has been informed of"

EDIT: forgot to mention - if you play at one of the resolutions that doesn't have a height of 480 (i.e. neither 640x480 or 720x480) then the black debugging lines will appear in entirely the wrong place and will not move completely in time with the landscape. This is because physics runs with unscaled geometry whereas the graphics are scaled to the viewport.

One other thing I meant to say, in addition to the existing possibility for arbitrarily positioned and orientated sprites that the player doesn't interact with and will always pass in front of, I intend to add support for others which the player will pass behind - effectively implementing level decorations.

Is anyone willing to knock up some trees or donkeys or other common seaside objects for the pure purpose of decoration? For the 'background' or 'foreground'.

Elias
Member #358
May 2000

Will there also be geometriy where the player is behind? Could then do things like giant textured trees :)

--
"Either help out or stop whining" - Evert

Thomas Harte
Member #33
April 2000
avatar

Oh, I guess there could be. It'd only be one extra variable in total per quadtree node and only a couple of extra tests in the while loops that do all the drawing. The ordering is based on ordering the linked list of objects at leaf nodes as a final processing step. For convenience, I'll probably put it in as an edge flag, which if found affects the drawing of the entire triangle. How does "foreground" sound as a flag applicable to either polygon edges with the effect just mentioned and also objects?

Elias
Member #358
May 2000

Sounds good. (In Blender, I would again just make it an object proeprty, and an object with that property would have all edges marked as "foreground".)

--
"Either help out or stop whining" - Evert

Thomas Harte
Member #33
April 2000
avatar

I'll make my complete list of jobs as follows then:

  • try fix of edges issue as described above

  • implement foreground properties

  • fix allegro_id error

  • disable all debugging features (e.g. black lines, printf's)

  • clean and document

And I'll try to put together a full list of extra resources it would be nice to have for the game. Hopefully Goodbytes is about to step into the breach as concerns in game music, so it'll just be a few dings and thuds soundwise plus whatever graphics are made available + a full demo map.

Hopefully source (not necessarily cleaned or documented yet) can be complete in three or four days for much wider testing.

Otherwise, lets see how much can be done in just 10 days!

P.s. don't forget to shout at me if I've missed anyone off the credits page, I haven't been keeping a brilliant track of who has provided what.

Goodbytes
Member #448
June 2000
avatar

Attached is the end of level sound, with some instruments changed, in MIDI format (see EDIT 3 below). This will save some space, as it's only about half a kilobyte, compared to the 172 kB wave sample (which I admittedly went a little overboard on, sound quality wise).

[EDIT]
By the way, Thomas: I'd like to test your new code to see if the vertical wall problem is fixed, but it crashes for me, too. Once you upload the new datafiles I'll give it a whirl. I'm also still working on the music :)

Oh, and since you and Miran are using your (as far as I know) real names, I had might as well use mine in the credits too. It's Nick Davies, when you get the chance to edit it in...

[EDIT 2]
Bug report: The palette gets slightly messed up when you return to the main menu from a game in progress. This is most noticeable in the title "Demo Game," which after returning from a game in progress, looks blue and orange instead of light blue.

[EDIT 3]
I've changed the attachment; now it's a zip with the end of level jingle in MIDI format and an updated version of the song I am writing for the game. I hope you like it. The song is currently about 2 minutes long, but I still have to put in the second theme that I've been writing, then a restatement of the first one just to wrap things up, so when I'm done it will likely be about 3 and a half minutes long. The 2 minutes that are here are not quite finished yet either, but I'm going to bed now. :) Enjoy!


--
~Goodbytes

Thomas Harte
Member #33
April 2000
avatar

I've literally just been to my house then come to my girlfriend's so no code fixes yet, but I did discover that I'd included the wrong level.txt in the old distribution. Switch it for the one attached and appended to this post and things 'should' work! In addition the method for adding objects to the level is vaguely documented in it.

Quote:

# NOTE 1: comments are started with a hash and run until end of line

#

  1. First - the material list. Materials listed here are later referenced by

  2. number according to their location in the list

#

  1. Parameters for each material are fill bitmap, then edge bitmap,

  2. then edge friction

#

  1. For the time being, references to bitmaps have .bmp appended and are loaded

  2. straight from the filesystem. Obviously a datafile or something will replace

  3. this system at some point

#
{
{"soil", "grass", 0.2}
}

#

  1. Second - point list.

#

  1. Each braced object is a vertex, later referenced by number

  2. according to list position

#
{
# 0
{84, 84}

# 1
{63, 6} {64, 0} {62, 12} {61, 18} {59, 24} {56, 30} {53, 35}
# 8
{49, 40} {45, 45} {40, 49} {35, 53} {30, 56} {24, 59} {18, 61}
# 15
{12, 62} {6, 63} {0, 64}

# 18
{-64, 64} {-148, 84}

# 20
{-128, 0} {-127, 6} {-126, 12} {-125, 18} {-123, 24} {-120, 30}
# 26
{-117, 35} {-113, 40} {-109, 45} {-104, 49} {-99, 53} {-94, 56}
# 32
{-88, 59} {-82, 61} {-76, 62} {-70, 63}

# 36
{-148, -128} {-128, -128}

# 38
{84, -88} {74, -88}
}

#

  1. Third - triangle list.

#

  1. Each big braced object is an individual triangle. Within that each vertex is

#Êbraced and after all three comes the material reference
#

  1. The vertices are described as {vertex, edge height [, flags] }

#

  1. Edge height affects how edges are drawn on the triangle and is an unsigned

  2. integer less than 128. Flags can be empty or can include any of the following:

#
# "edge" - an edge is drawn on the triangle between this vertex
# and the next
#
# "collidable" - the player will stand on this edge rather than passing
# through it
#
{
{
{0, 0},
{1, 2, "edge" "collidable"},
{2, 2},
0
}
{
{0, 0},
{3, 2, "edge" "collidable"},
{1, 2},
0
}
{
{0, 0},
{4, 2, "edge" "collidable"},
{3, 2},
0
}
{
{0, 0},
{5, 2, "edge" "collidable"},
{4, 2},
0
}
{
{0, 0},
{6, 2, "edge" "collidable"},
{5, 2},
0
}
{
{0, 0},
{7, 2, "edge" "collidable"},
{6, 2},
0
}
{
{0, 0},
{8, 2, "edge" "collidable"},
{7, 2},
0
}
{
{0, 0},
{9, 2, "edge" "collidable"},
{8, 2},
0
}
{
{0, 0},
{10, 2, "edge" "collidable"},
{9, 2},
0
}
{
{0, 0},
{11, 2, "edge" "collidable"},
{10, 2},
0
}
{
{0, 0},
{12, 2, "edge" "collidable"},
{11, 2},
0
}
{
{0, 0},
{13, 2, "edge" "collidable"},
{12, 2},
0
}
{
{0, 0},
{14, 2, "edge" "collidable"},
{13, 2},
0
}
{
{0, 0},
{15, 2, "edge" "collidable"},
{14, 2},
0
}
{
{0, 0},
{16, 2, "edge" "collidable"},
{15, 2},
0
}
{
{0, 0},
{17, 2, "edge" "collidable"},
{16, 2},
0
}

{
{18, 2, "edge" "collidable"},
{17, 2},
{0, 0},
0
}
{
{18, 2},
{0, 2},
{19, 0},
0
}

{
{19, 0},
{20, 2, "edge" "collidable"},
{21, 2},
0
}
{
{19, 0},
{21, 2, "edge" "collidable"},
{22, 2},
0
}
{
{19, 0},
{22, 2, "edge" "collidable"},
{23, 2},
0
}
{
{19, 0},
{23, 2, "edge" "collidable"},
{24, 2},
0
}
{
{19, 0},
{24, 2, "edge" "collidable"},
{25, 2},
0
}
{
{19, 0},
{25, 2, "edge" "collidable"},
{26, 2},
0
}
{
{19, 0},
{26, 2, "edge" "collidable"},
{27, 2},
0
}
{
{19, 0},
{27, 2, "edge" "collidable"},
{28, 2},
0
}
{
{19, 0},
{28, 2, "edge" "collidable"},
{29, 2},
0
}
{
{19, 0},
{29, 2, "edge" "collidable"},
{30, 2},
0
}
{
{19, 0},
{30, 2, "edge" "collidable"},
{31, 2},
0
}
{
{19, 0},
{31, 2, "edge" "collidable"},
{32, 2},
0
}
{
{19, 0},
{32, 2, "edge" "collidable"},
{33, 2},
0
}
{
{19, 0},
{33, 2, "edge" "collidable"},
{34, 2},
0
}
{
{19, 0},
{34, 2, "edge" "collidable"},
{35, 2},
0
}
{
{19, 0},
{35, 2, "edge" "collidable"},
{18, 2},
0
}

{
{19, 2},
{20, 2},
{36, 0},
0
}
{
{36, 2, "edge" "collidable"},
{37, 2, "collidable"},
{20, 0},
0
}

{
{0, 2},
{38, 0},
{2, 2},
0
}
{
{38, 2},
{2, 0, "collidable"},
{39, 2, "edge" "collidable"},
0
}
}

#

  1. Fourth - object type list. Each object type is a bitmap name followed by

  2. a sample name

#
{
{ "orange", "" }
}

#

  1. Fifth - object list. x, y, angle (in degrees), object type, flags

#

  1. NB: any negative object type is interpreted to be the exit door!

#
{
{64, -600, 0, 0, "collidable"}
{-200, -200, 0, -1, "collidable"}
}

#

  1. Finally, some basic pieces of level information - player start x,y then

  2. number of objects required for collection before the level ends

#
{
0, -150, 1
}

Goodbytes
Member #448
June 2000
avatar

The vertical wall bug is fixed now :) The game plays well, but I didn't really like how after dashing up the left wall of the half pipe and "flying" straight up and off the ground, when coming back down again, the character would land on the rim of the half pipe. I think it would be much preferable to continue sliding on the half pipe on the way down instead, if this is possible. Otherwise, it's fun. :)


--
~Goodbytes

Thomas Harte
Member #33
April 2000
avatar

Quote:

The game plays well, but I didn't really like how after dashing up the left wall of the half pipe and "flying" straight up and off the ground, when coming back down again, the character would land on the rim of the half pipe. I think it would be much preferable to continue sliding on the half pipe on the way down instead, if this is possible. Otherwise, it's fun.

Probably a rounding error, although the whole thing is a bit confusing because the main sprite is thinner than the collision object. Krajzega was working on a better proportioned sprite before being deluged by exams.

Anyway, MIDIs sound good and I'm just about to incorporate them (my development machine being renetworked for the time being). Otherwise foreground items are now implemented and the non-constant initialiser error is gone. So it's probably a matter of clean that up, fix the 'edge extension' problem explained by Evert and then the code is functionally complete although still overwhelmingly undocumented and a touch messy.

Is someone who knows Blender willing to do substantial work towards getting a decent demo level?

Elias
Member #358
May 2000

Ok, new Blender export, now with full objects support. I started making a level, but I seem to run into an invisible obstacle. Maybe you can find out what the problem is? It may very well be my exporter.. the attached .zip includes the blender file as well as the exported level. Oh, and anyone knows if you can get Blender to reduce the number of faces in a mesh? It can do it for rendering.. but I'd like to reduce the faces also for exporting.

Here's the script (the help can also be read from inside Blender under "Help->Scripts Browser"):

[Edit: This is what the level looks like in Blender]
[img http://allefant.sf.net/uploads/hilly.png]

#SelectExpand
1#!BPY 2# Version 6: merge object types, round numbers to integer 3# Version 5: objects 4# Version 4: read edge_height property 5# Version 3: process geometry into clockwise triangles 6# Version 2: materials 7# Version 1: only mesh geometry 8 9""" 10Name: 'Allegro Demo Game Level (.txt)...' 11Blender: 237 12Group: 'Export' 13Tooltip: 'Export Allegro Demo Game Level (.txt)' 14""" 15__bpydoc__ = """\ 16All mesh objects are exported as triangles. Coordinates are scaled by a factor 17of 10, so something at lender coordinate x=10 will be x=100 in the game. And the 18y axis is flipped, since in the game, positive y is downwards. 19 20Every mesh must have a material assigned for each of its faces. You can do this 21by just giving a meterial to the mesh object, or also by applying per-face 22materials. 23 24A material must have texture slot 0 and 1 filled in and set to Image textures, 25where the first texture's image is the base texture, and the second the edge 26texture. All other material settings are ignored. 27 28Objects are inserted as Blender "Empties". Each object has the following 29properties: 30 31"bitmap" - name of the bitmap to use 32"sound" - name of the sound to play 33 34There are some reserved names. Empties whose name starts with "player" or 35"Player" mark the player starting position. Empties whose name starts with 36"exit" or "Exit" mark the level exit position. 37 38All other objects (cameras, lamps, ...) are ignored. 39 40Currently, there is no sanity checking done, so be sure to: 41- Assign materials to meshes/faces. 42- Make only 2D meshes. Blender will happily twist your meshes around, but the 43 exported level simply will crash. Only a planar mesh is allowed. 44- Don't forget the Empties for the player and exit positions, and set at least 45 one other collectible. 46""" 47 48import Blender, meshtools, sys, time 49 50# scaling factor when exporting vertex coordinates from blender 51SCALE_X = 10 52SCALE_Y = -10 53 54# can be modified on a per-mesh basis via the "edge_height" property 55DEFAULT_EDGE_HEIGHT = 2 56 57# cannot be modified right now 58DEFAULT_FRICTION = 0.2 59 60def transform(matrix, vector): 61 """ 62 Given a matrix and a vector, return the result of transforming the vector by 63 the matrix. 64 matrix = [[0, 0, 0, 0], [0, 0, 0, 0]] 65 vector = [0, 0, 0, 0] 66 return = [0, 0] 67 """ 68 vout = [] 69 for j in range(2): 70 x = 0 71 for i in range(4): 72 x += matrix<i>[j] * vector<i> 73 vout += [x] 74 return vout 75 76 77def direction(tri): 78 """ 79 Given a triangle, determine if it is counterclockwise or not. 80 tri = [[i, i], [i, i], [i, i]], 81 where i is a global vertex index. 82 """ 83 v1 = (V[tri[1]][0] - V[tri[0]][0], V[tri[1]][1] - V[tri[0]][1]) 84 v2 = (V[tri[2]][0] - V[tri[1]][0], V[tri[2]][1] - V[tri[1]][1]) 85 v = v1[0] * v2[1] - v1[1] * v2[0] 86 return v 87 88def get_prop(ob, name, val): 89 try: 90 prop = ob.getProperty(name) 91 v = prop.getData() 92 except AttributeError: 93 v = val 94 return v 95 96def write(filename): 97 global V 98 file = open(filename, "wb") 99 stdout = sys.stdout 100 sys.stdout=file 101 102 print "# Exported from Blender %s" % Blender.Get("version") 103 print "# on %s (%s)" % (time.ctime(), time.tzname[0]) 104 print "# do not edit, edit %s instead" % Blender.Get("filename") 105 print 106 107 # Retrieve a list of all mesh objects in Blender. 108 meshobs = [ob for ob in Blender.Object.Get() if ob.getType() == "Mesh"] 109 110 # Export all current Blender materials. 111 mnum = 0 112 materials = {} 113 print "# Materials" 114 print "{" 115 for m in Blender.Material.Get(): 116 t = [] 117 for tex in m.getTextures()[:2]: 118 if tex and tex.tex.getImage(): 119 t += [tex.tex.getImage().name.split(".")[0]] 120 else: 121 t += [""] 122 print """\t{"%s", "%s", %.1f} # %d \"%s\"""" % (t[0], t[1], 123 DEFAULT_FRICTION, mnum, m.getName()) 124 materials[m.name] = mnum 125 mnum += 1 126 print "}" 127 print 128 129 # Export all vertices of all mesh objects. 130 V = {} 131 print "# Vertices" 132 print "{" 133 i = 0 134 for ob in meshobs: 135 matrix = ob.matrix 136 mesh = ob.getData() 137 print "\t# Mesh \"%s\"" % mesh.name 138 for v in mesh.verts: 139 pos = transform(matrix, [v.co.x, v.co.y, v.co.z, 1]) 140 V<i> = pos 141 print "\t{%d, %d} # %d" % (round(pos[0] * SCALE_X), 142 round(pos[1] * SCALE_Y), i) 143 i += 1 144 print "}" 145 print 146 147 # Mark boundary edges. Every edge which is part of exactly one face is a 148 # boundary edge. 149 boundaries = {} 150 base_i = 0 151 for ob in meshobs: 152 mesh = ob.getData() 153 for f in mesh.faces: 154 prev = f.v[-1] 155 for v in f.v: 156 vs = [base_i + prev.index, base_i + v.index] 157 vs.sort() 158 vs = tuple(vs) 159 if vs in boundaries: 160 boundaries[vs] += 1 161 else: 162 boundaries[vs] = 1 163 prev = v 164 base_i += len(mesh.verts) 165 166 # Export all faces of all mesh objects (split into triangles). 167 print "# Triangles" 168 print "{" 169 170 base_i = 0 171 for ob in meshobs: 172 mesh = ob.getData() 173 174 meshmaterials = mesh.getMaterials(1) 175 176 try: 177 prop = ob.getProperty("edge_height") 178 edge_height = int(prop.getData()) 179 except AttributeError: 180 edge_height = DEFAULT_EDGE_HEIGHT 181 182 print "\t# Mesh \"%s\"" % mesh.name 183 for f in mesh.faces: 184 # First triangle. 185 tri1 = [base_i + f.v[2].index, base_i + f.v[1].index, base_i + 186 f.v[0].index] 187 if direction(tri1) > 0: 188 tri1.reverse() 189 tris = [tri1] 190 191 # If the face has 4 vertices, add another triangle. 192 if len(f.v) > 3: 193 tri2 = [tri1[2], base_i + f.v[3].index, tri1[0]] 194 if direction(tri2) > 0: 195 tri2.reverse() 196 tris += [tri2] 197 198 for tri in tris: 199 # Handle one triangle. 200 print "\t{" 201 for i in range(3): 202 v = tri<i> 203 if i == 2: 204 next = tri[0] 205 else: 206 next = tri[i + 1] 207 flags = "" 208 vs = [v, next] 209 vs.sort() 210 vs = tuple(vs) 211 if vs in boundaries and boundaries[vs] == 1: 212 flags = ", \"collidable\" \"edge\"" 213 print "\t\t{%d, %d%s}," % (v, edge_height, flags) 214 print "\t\t%d" % materials[meshmaterials[f.mat].name] 215 print "\t}" 216 base_i += len(mesh.verts) 217 print "}" 218 print 219 220 # Retrieve a list of all empty objects in Blender. 221 gameobs = [ob for ob in Blender.Object.Get() if ob.getType() == "Empty"] 222 223 obtypes = {} 224 n = 0 225 226 print "# Object types" 227 print "{" 228 for ob in gameobs: 229 if get_prop(ob, "player", False): 230 continue 231 if get_prop(ob, "exit", False): 232 continue 233 bitmap = get_prop(ob, "bitmap", "") 234 sound = get_prop(ob, "sound", "") 235 236 if not (bitmap, sound) in obtypes: 237 print "\t{ \"%s\", \"%s\" } # %d" % (bitmap, sound, n) 238 obtypes[(bitmap, sound)] = n 239 n += 1 240 print "}" 241 print 242 243 print "# Objects" 244 print "{" 245 for ob in gameobs: 246 if ob.name.lower().startswith("player"): 247 continue 248 x, y, z = ob.getLocation() 249 anglex, angley, anglez = ob.getEuler() 250 if ob.name.lower().startswith("exit"): 251 type = -1 252 else: 253 bitmap = get_prop(ob, "bitmap", "") 254 sound = get_prop(ob, "sound", "") 255 type = obtypes[(bitmap, sound)] 256 flags = ", \"collidable\"" 257 print "\t{ %d, %d, %d, %d%s } # \"%s\"" % (round(x * SCALE_X), round(y * SCALE_Y), 258 round(anglez), type, flags, ob.name) 259 print "}" 260 print 261 262 print "# Level" 263 print "{" 264 for ob in gameobs: 265 if ob.name.lower().startswith("player"): 266 x, y, z = ob.getLocation() 267 print "\t%d, %d, %d" % (round(x * SCALE_X), round(y * SCALE_Y), n) 268 break 269 print "}" 270 271 sys.stdout = stdout 272 273def fs_callback(filename): 274 # Mesh access is better done outside edit mode I believe. 275 editmode = Blender.Window.EditMode() 276 if editmode: Blender.Window.EditMode(0) 277 write(filename) 278 if editmode: Blender.Window.EditMode(1) 279 280Blender.Window.FileSelector(fs_callback, "Export Allegro Demo Game Level", 281 "mylevel.txt")

--
"Either help out or stop whining" - Evert

Thomas Harte
Member #33
April 2000
avatar

Quote:

I started making a level, but I seem to run into an invisible obstacle. Maybe you can find out what the problem is? It may very well be my exporter..

No invisible obstacle on my computer, so it is almost certainly not the exporter! But I have tweaked the rounding error stuff with respect to something a lot like an invisible obstacle that was causing the player to catch on the top left edge in the small level I previously had.

If there's any chance that the input level has edges set as collidable that are directly connected to other triangles then that may well be it. I need to add a filter to my code to remove those.

Quote:

merge object types, round numbers to integer

It shouldn't need integers - were floats causing problems?

By the way, there are actually already bitmaps for an icy surface and four other object types in the datafiles (well there may not be in the last set, but there are now). The extra surface is composed as follows:

{"ice", "icetip", 0.2}

And the objects:

{ "bananas", "" }
{ "sweet", "" }
{ "cherries", "" }
{ "icecream", "" }

(Notice: still no sounds for these!)

Elias
Member #358
May 2000

Quote:

No invisible obstacle on my computer, so it is almost certainly not the exporter! But I have tweaked the rounding error stuff with respect to something a lot like an invisible obstacle that was causing the player to catch on the top left edge in the small level I previously had.

Well, here, I can't get up the very first upwards slop in my level.. is it possible to get the black debug lines back? They would maybe reveal what is going on.

Quote:

It shouldn't need integers - were floats causing problems?

No, but I first thought maybe that's what's causing the invisible edges. Can add them again, but I guess there's no need really.

Quote:

Is someone who knows Blender willing to do substantial work towards getting a decent demo level?

I'll try to expand my level so it is somewhat playable. But so far, it won't have much interesting things, just a slopy hill and some fruits to collect along the way :) I'll try to decimate the number of faces, and once I can get past the first slope with that invisible edge fixed, adjust the fruit positions..

--
"Either help out or stop whining" - Evert

Thomas Harte
Member #33
April 2000
avatar

Attached is a relatively broken version which I hope will reveal whether the invisible collision bug is gone. It includes fixes to collisions and visibly substantial quad tree fixes for those viewing above 720x480 resolution, as well as the "foreground" property for triangles (via edges) and objects. Draw order is now:

  • draw background objects

  • draw background triangles

  • draw background triangle edges

  • draw player

  • draw foreground objects

  • draw foreground triangles

  • draw foreground triangle edges

The drop shadow on the menu and intro font is broken (an erroneous palette fix, I'm afraid) and most pressingly the thing seems to crash if you try to enter the game environment more than once (e.g. selecting 'new game' a second time or 'continue game' at all).

Nevertheless, the debug lines are enabled again so hopefully we can knock this collision error on the head with this copy. Note that they'll only appear in the correct places in 640x480 or 720x480 mode!

Elias
Member #358
May 2000

Ok, thanks, trying it now..

Hm, sigsegv :|

#0  0x08068050 in OrderTree (Tree=0x85aa834, PostTree=-1) at QuadTree.c:719
719                                     PNext = P->Next;
(gdb) bt
#0  0x08068050 in OrderTree (Tree=0x85aa834, PostTree=-1) at QuadTree.c:719
#1  0x08068005 in OrderTree (Tree=0x85a8b94, PostTree=-1) at QuadTree.c:706
#2  0x08068005 in OrderTree (Tree=0x81e6cc8, PostTree=-1) at QuadTree.c:706
#3  0x0806461d in LoadLevel (name=0x80ff420 "level.txt", radius=14) at Level.c:953
#4  0x0805fd82 in LoadResources (Restart=-1) at Game.c:373
#5  0x080600b7 in GameInit () at Game.c:427
#6  0x0805eeb3 in run () at framework.c:195
#7  0x0805e48b in main () at demo.c:9

--
"Either help out or stop whining" - Evert

Thomas Harte
Member #33
April 2000
avatar

Ah, before even being able to get in once? This is the thing I was referring to when I said "most pressingly the thing seems to crash if you try to enter the game environment more than once" so it's not exactly "a surprise".

I'll fix that right now. It'll be something to do with my reordering of things just now so that triangles are scaled before being put into the display tree.

EDIT: fixed it. Substitute the attached QuadTree.c for the one in the old archive. Or else change line 169 to read:

Tree->NumContents = 0; Tree->Contents = Tree->PostContents = NULL;

Rather than simply:

Tree->NumContents = 0; Tree->Contents = NULL;

Elias
Member #358
May 2000

Yes, i compiled, started, and that's what i got when hitting enter two times. (Oh, and I just found out Blender has a nice mesh decimation tool, should reduce the size of my level somewhat..)

[Oh, and I'm in #allegro right now, in case a lot of testing will be needed might be easier to communicate there..]

--
"Either help out or stop whining" - Evert

Richard Phipps
Member #1,632
November 2001
avatar

I thought all this vector math magic was supposed to make things easier! :)



Go to: