• What do you need help with? Version 1
    5,001 replies, posted
Append a little test to it [code]_root.bulletArray.push(bullet); if (bullet == _root.bulletArray[_root.bulletArray.length - 1]) trace("I'm in the array alright.\n");[/code] Maybe even look that attachMovie movie does not bug: [code]for (i=0; i<_root.bulletArray.length - 1; ++i) if (bullet == _root.bulletArray[i]) trace("I shouldn't be in here more than once...\n");[/code]
I'm getting both traces, i'm not sure what that means though and the one that shouldn't be in there more than once, plenty of times
I'm guessing that the whole array consists of the same bullet. The first trace-output shows that the last element is the bullet as returned by attachMovie. The seconds one shows, how many times that the is in the array. Should be correct, as long as it's not comparing names. But choosing different names for each bullet might fix it: [code]bullet = _root.attachMovie("bullet", "bull" + _root.bulletArray.length, _root.getNextHighestDepth());[/code]
You should try using duplicateMovieClip instead of attach movie. I think the syntax is the same except the first parameter is MovieClip and not string. [URL="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary194.html"]http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary194.html[/URL]
Sweet, works perfectly now, thanks, and i'll check out duplicateMovieClip for later use
I need help ;__; I'm learning C++ and in my book, it has me do exercises after each section. Right now it's teaching me Functions. I seem to have a problem here... This is what the book says: [quote] Write a function named [B]print_out[/B] that prints all the whole numbers from 1 to N. Test the function by placing it in a program that passes a number n to it, where this number is entered from the keyboard. The print_out function should have type [B]void[/B]; it does not return a value. The function can be called with a simple statement: [B]print_out(n);[/B] [/quote]I looked over it for a bit and thought I knew what to do, however, I don't. Any help would be appreciated :( My code: [code] #include <iostream> #include <math.h> using namespace std; int triangle(int num); int main() { int n; cout << "Enter a number and press ENTER: "; cin >> n; cout << "Function returned " << triangle(n); return 0; } int triangle(int n) { int i; int sum = 1; for (i = 1; i <= n; i++) { sum *= i; } return sum; } [/code] Basically what I'm saying is I don't know how to make the print_out function that it asks for.
anyone know of a way to make it so you can't just hold down a key to continuously keep a condition going in AS2? tried a couple of ways, less than satisfactory results
@slayer20 I'm still a newbie too, but I hope that helps: [code] #include <iostream> using namespace std; void print_out( int n ); int main() { int value; cout << "Enter a number and press ENTER : "; cin >> value; cout << "Output : "; print_out( value ); return 0; } void print_out( int n ) { for( int i = 1; i <= n; i++) { cout << i << ", "; } } [/code]
[QUOTE=Parakon;22765761]anyone know of a way to make it so you can't just hold down a key to continuously keep a condition going in AS2? tried a couple of ways, less than satisfactory results[/QUOTE] onMouseRelease.
Thanks Zeonho, that worked. I'll have to play around with it some more so I can get a better understanding of how to use it.
General OpenGL question. I'm trying to start working in 3D and I want to display a rectangle and a triangle but I doesn't display anything. Can you tell me what I'm doing wrong? [cpp]using System; using System.Collections.Generic; using System.Linq; using System.Text; using Tao.Glfw; using Tao.OpenGl; using System.Runtime.InteropServices; namespace DoomClone { class World { private double lastTime; public float FrameTime; private bool IsRunning; private float frameCounter; float[] light_diffuse = { 100F, 0.0F, 0.0F, 100F }; float[] light_position = { 100F, 100F, 100F, 0.0F }; public List<DisplayObject> Meshes = new List<DisplayObject>(); [DllImport( "kernel32.dll", ExactSpelling = true )] private static extern IntPtr GetConsoleWindow (); private static IntPtr MyConsole = GetConsoleWindow(); [DllImport( "user32.dll", EntryPoint = "SetWindowPos" )] public static extern IntPtr SetWindowPos ( IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags ); public World () { SetWindowPos( MyConsole, 0, 814, 0, 0, 0, 1 ); Glfw.glfwInit(); Glfw.glfwOpenWindow( 800, 600, 8, 8, 8, 8, 64, 0, Glfw.GLFW_WINDOW ); Gl.glClearColor( 0, 0, 0, 0.5F ); Gl.glClearDepth( 1.0f ); Glu.gluPerspective( 40.0, 1.333, 0.5, 1000 ); Gl.glViewport( 0, 0, 1, 1 ); Gl.glMatrixMode( Gl.GL_MODELVIEW ); Gl.glLoadIdentity(); Gl.glShadeModel( Gl.GL_SMOOTH ); Gl.glEnable( Gl.GL_DEPTH_TEST ); Gl.glDepthFunc( Gl.GL_LEQUAL ); Gl.glHint( Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST ); Glfw.glfwSwapInterval( 0 ); } public void Init () { IsRunning = true; while ( IsRunning ) { double currentTime = Glfw.glfwGetTime(); FrameTime = (float)( currentTime - lastTime ); lastTime = currentTime; Glfw.glfwSetWindowTitle( ( FrameTime * 1000 ).ToString() ); frameCounter += FrameTime; if ( frameCounter >= 0.016 ) { Render(); frameCounter = 0; } if ( Glfw.glfwGetWindowParam( Glfw.GLFW_OPENED ) == Gl.GL_FALSE || Glfw.glfwGetKey( Glfw.GLFW_KEY_ESC ) == Glfw.GLFW_PRESS ) { IsRunning = false; } } } private void Render () { Gl.glClear( Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT ); // Clear Screen And Depth Buffer Gl.glLoadIdentity(); Gl.glColor3f( 1, 1, 1 ); Gl.glTranslatef( -1.5f, 0.0f, -6.0f ); Gl.glBegin( Gl.GL_TRIANGLES ); Gl.glVertex3f( 0.0f, 1.0f, 0.0f ); Gl.glVertex3f( -1.0f, -1.0f, 0.0f ); Gl.glVertex3f( 1.0f, -1.0f, 0.0f ); Gl.glEnd(); Gl.glTranslatef( 3.0f, 0.0f, 0.0f ); Gl.glBegin( Gl.GL_QUADS ); Gl.glVertex3f( -1.0f, 1.0f, 0.0f ); Gl.glVertex3f( 1.0f, 1.0f, 0.0f ); Gl.glVertex3f( 1.0f, -1.0f, 0.0f ); Gl.glVertex3f( -1.0f, -1.0f, 0.0f ); Gl.glEnd(); Glfw.glfwSwapBuffers(); } } } [/cpp]
[QUOTE=Darwin226;22770295]onMouseRelease.[/QUOTE] isn't that just for mouse functions? i'm looking for keys
onKeyUp
Yep, sorry. Didn't read the post correctly. If you used AS3 I could solve it for you now problem, I just don't remember how it is in AS2. Try something with onKeyRelease or something. EDIT: Zeeky could you maybe look at my code for a second and tell me if you spot something that I did wrong?
I at first thought that glColor3f has to be within glBegin and glEnd, but it seems that you can call it any time. I didn't really check your coordinate setup, it's been some time since I used immediate mode, but possibly the coordinates are wrong or the near or far-clip planes clip the geometry?
The near is 0.5 and far is 1000 that isn't the problem. Well I have an example that works so I'll see if there are any differences in the code.
glTranslatef( -1.5f, 0.0f, -6.0f ); Shouldn't that put the triangle and the quad even behind the camera? z is forward, right?
Negative-Z translates the world forwards.
Why does almost everyone use Z for forward and not up? Everything I've seen that uses 3D coordinates (3DS Max, Source engine, ...) uses Z for up.
Well it makes more sense since in 2D X is left-right, Y is up-down. [editline]07:39PM[/editline] Also, making the value positive, setting it to 0, removing the translate all together makes no difference, just a sad black screen...
I know it makes more sense, but it seems all the commercial stuff uses Z for up.
[QUOTE=Overv;22777556]Why does almost everyone use Z for forward and not up? Everything I've seen that uses 3D coordinates (3DS Max, Source engine, ...) uses Z for up.[/QUOTE] Because 2D has X as left and right and Y as up and down. The third dimension is depth, forward and back. Ninja'd Anyway, the commercial stuff is wrong.
Darwin, why is your viewport 1 by 1 pixel big?
Uhh I'm pretty sure that the nomenclature of the axis doesn't matter. It could be p, g, f and it still means the same shit.
It was something I was trying, changed that later with no effect. Aaaaaanyways I got it working! I HAVE A FRICKIN' ROTATING RAINBOW PLANE! Wow I'm badass, watch out Crytek.
It was the viewport wasn't it? :v: [b]Edit:[/b] You also forgot to set the matrix mode to GL_PROJECTION: [cpp]glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 40.0, 1.333, 0.5, 1000 );[/cpp]
Nope, actually something was wrong with the draw code, replaced it with something else and it draws stuff now. The strange thing is that the viewport is at 800,600. I'm drawing this triangle: [cpp] Gl.glBegin( Gl.GL_TRIANGLES ); Gl.glColor3f( 1.0f, 0.0f, 0.0f ); Gl.glVertex3f( -25.0f, -25.0f, 0.0f ); Gl.glColor3f( 0.0f, 1.0f, 0.0f ); Gl.glVertex3f( 0.0f, 25.0f, 0.0f ); Gl.glColor3f( 0.0f, 0.0f, 1.0f ); Gl.glVertex3f( 25.0f, -25.0f, 0.0f ); Gl.glEnd();[/cpp] It takes up the whole screen and I can barely see the edges when it rotates. EDIT: Why the rainb.... ohhhh. It's the rainbow plane isn't it. Can someone tell me how to put a texture to something?
You can use [url=http://www.lonesock.net/soil.html][b]SOIL[/b][/url] to load textures from common image formats. You can make a texture active by using: [cpp]glBindTexture( GL_TEXTURE_2D, texture );[/cpp] And then you specify the texture coordinates with glTexCoord2f.
Gl.glViewport( 0, 0, 1, 1 ); Maps the screen to (0,0) to (1,1). So either set that higher or make the triangle smaller.
As I said, I've set the viewport to 0,0,800,600. Also, thanks for the texture info. EDIT: Is there anything like SOIL for Tao? How do I do it otherwise?
Sorry, you need to Log In to post a reply to this thread.