Forums

Some help

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Some help

Postby zengeek » Mon Oct 25, 2010 11:21 am

I'm trying to run a simple example of a game engine just like XNA, but i'm not being able to. Can someone tell me if this code has something wrong, it gives me this error:
"Cannot find namespace Vortex" but the paths are ok...

@args lib:"E:\Compartilhada\Dev\Vortex2D\Bin\Lib\Vortex.dll"
@args lib:"E:\Compartilhada\Dev\Vortex2D\Bin\Lib\Vortex.Core.dll"

@ref 'Vortex'
@ref 'Vortex.Core'
@ref 'System.Drawing'

@number float32


use Vortex
use Vortex.Drawing


class GameTest inherits Game

cue init
base.init
.window.width = 800
.window.height = 600
.window.title = 'Vortex Cobra'

def load is override, protected
pass

def unload is override, protected
pass

def update(time as GameTime?) is override, protected
base.update(time)

def render(canvas as Canvas2D?) is override, protected
canvas.clear(ColorU.CornflowerBlue)

def main
.run
zengeek
 
Posts: 8

Re: Some help

Postby Charles » Mon Oct 25, 2010 3:19 pm

It looks like your -lib directive is including the path all the way down to the file. But it only needs the directory to look into. Try:

@args -lib:"@args -lib:"E:\Compartilhada\Dev\Vortex2D\Bin\Lib"

If it still does not work, include the output of "cobra -v ..."

Did you create the Vortex libs yourself or is that a public project? Is there a URL for it?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Some help

Postby zengeek » Mon Oct 25, 2010 6:49 pm

ok , i'll try that. thanks
about vortex, it's a 2d game engine for .net : http://vortex2d.codeplex.com/
zengeek
 
Posts: 8

Re: Some help

Postby zengeek » Mon Oct 25, 2010 7:23 pm

When i changed the lib line it changed to this exception: COBRA INTERNAL ERROR / FormatException / Input string was not in a correct format
I analyzed the code and found that what's causing the exception is this line : 'canvas.clear(ColorU.CornflowerBlue)', wich translates to 'ColorU(100, 149, 237)' internally. So the error seems to be about the color type format. The XNA example uses _graphics.graphicsDevice.clear(Color.cornflowerBlue) , internally it translates to 'Color(0xff6495ed)' , a uint type. I've tried
passing 'ColorU(0xff6495ed)', 'ColorU(100, 149, 237)' and nothing, same error. If i remove 'canvas.clear(ColorU.CornflowerBlue)' it compiles successfully..., but obviously does not run since it depends on the DLL's of the engine...

The result of compiling with -v:


Code: Select all
C:\Users\Rafael\Desktop>cobra -c -v vortexcobra.cobra
Cobra Command Line 0.8.0 post-release
Copyright (C) 2003-2010 by Cobra Language LLC.

OS Version:   Microsoft Windows NT 6.1.7600.0
CLR Platform: .NET
CLR Version:  2.0.50727.4952
Current Directory: C:\Users\Rafael\Desktop
Current Exe: C:\Cobra\Cobra-0.8.0-post\bin\cobra.exe
Option Dictionary:
    compile: true
    verbosity: 1
    back-end: 'none'
    contracts: 'inline'
    correct-source: Set<of String>['none']
    debugging-tips: true
    embed-run-time: false
    include-asserts: true
    include-nil-checks: true
    include-tests: true
    include-traces: true
    native-compiler: 'auto'
    number: 'decimal'
    test-runner: 'Cobra.Lang.CobraCore.runAllTests'
    testify-results: 'r-testify'
Paths:
    vortexcobra.cobra
Phase: Binding Cobra run-time library
Adding reference to Cobra.Lang.dll
Phase: Reading libraries
Reading assembly:  mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b7
7a5c561934e089
              at:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
Reading assembly:  System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a
5c561934e089
              at:  C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089
\System.dll
Loading reference: Cobra.Lang.dll
Reading assembly:  Cobra.Lang, Version=0.8.0.1, Culture=neutral, PublicKeyToken=
0a4783a5c7c9616e
              at:  C:\Windows\assembly\GAC_MSIL\Cobra.Lang\0.8.0.1__0a4783a5c7c9
616e\Cobra.Lang.dll
Phase: Parsing source code
Setting option "back-end" to default value none.
Setting option "contracts" to default value inline.
Setting option "correct-source" to default value {'none'}.
Setting option "debugging-tips" to default value true.
Setting option "embed-run-time" to default value false.
Setting option "include-asserts" to default value true.
Setting option "include-nil-checks" to default value true.
Setting option "include-tests" to default value true.
Setting option "include-traces" to default value true.
Setting option "native-compiler" to default value auto.
Setting option "number" to default value decimal.
Setting option "test-runner" to default value Cobra.Lang.CobraCore.runAllTests.
Setting option "testify-results" to default value r-testify.
parseToOptions Option Dictionary:
    library-directory: List<of String>['E:\Compartilhada\Dev\Vortex2D\Bin\Lib']
    back-end: 'none'
    contracts: 'inline'
    correct-source: Set<of String>['none']
    debugging-tips: true
    embed-run-time: false
    include-asserts: true
    include-nil-checks: true
    include-tests: true
    include-traces: true
    native-compiler: 'auto'
    number: 'decimal'
    test-runner: 'Cobra.Lang.CobraCore.runAllTests'
    testify-results: 'r-testify'
preAugment Options Dictionary
    compile: true
    verbosity: 1
    back-end: 'none'
    contracts: 'inline'
    correct-source: Set<of String>['none']
    debugging-tips: true
    embed-run-time: false
    include-asserts: true
    include-nil-checks: true
    include-tests: true
    include-traces: true
    native-compiler: 'auto'
    number: 'decimal'
    test-runner: 'Cobra.Lang.CobraCore.runAllTests'
    testify-results: 'r-testify'
    reference: List<of String>['Cobra.Lang.dll']
Adding library-directory "E:\Compartilhada\Dev\Vortex2D\Bin\Lib"
post augmentOptions
    compile: true
    verbosity: 1
    back-end: 'none'
    contracts: 'inline'
    correct-source: Set<of String>['none']
    debugging-tips: true
    embed-run-time: false
    include-asserts: true
    include-nil-checks: true
    include-tests: true
    include-traces: true
    native-compiler: 'auto'
    number: 'decimal'
    test-runner: 'Cobra.Lang.CobraCore.runAllTests'
    testify-results: 'r-testify'
    reference: List<of String>['Cobra.Lang.dll']
    library-directory: List<of String>['E:\Compartilhada\Dev\Vortex2D\Bin\Lib']
Loading reference: Vortex.dll
Reading assembly:  Vortex, Version=0.7.0.0, Culture=neutral, PublicKeyToken=null

              at:  E:\Compartilhada\Dev\Vortex2D\Bin\Lib\Vortex.dll
Loading reference: Vortex.Core.dll
Reading assembly:  Vortex.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken
=null
              at:  E:\Compartilhada\Dev\Vortex2D\Bin\Lib\Vortex.Core.dll
Phase: Binding use directives
Phase: Binding inheritance
Phase: Binding interface
Phase: Computing matching base members
Phase: Binding implementation
Reading assembly:  System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyTo
ken=b03f5f7f11d50a3a
              at:  C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f
11d50a3a\System.Drawing.dll
error: COBRA INTERNAL ERROR / FormatException / Input string was not in a correct format
Compilation failed - 1 error, 0 warnings
zengeek
 
Posts: 8

Re: Some help

Postby Charles » Mon Oct 25, 2010 7:57 pm

When I compile, I get:

x-vortex.cobra(37): error: Cannot find a definition for "CornflowerBlue" in "ColorU". There are members with similar names including ".cornflowerBlue", ".b", ".blue" and ".r".

After fixing the case, the compilation succeeds. Running the program fails, because .NET will not locate DLLs in "lib" directories even if you compiled a C# program with an explicit "lib" argument. But after copying the Vortex DLLs into the same directory, the program runs and displays FPS in the hundreds.

I'm on Win 7 32-bit as Administrator using the latest Cobra from source.

I have not tested with the last release. Are you using the very latest source, the last 2010-10-18 release or something else?
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Some help

Postby zengeek » Mon Oct 25, 2010 9:11 pm

i tried with cornflowerBlue, same error. I'm using the last release and windows seven 64bit. (Changed config to build all to 32bit btw...)
zengeek
 
Posts: 8

Re: Some help

Postby zengeek » Mon Oct 25, 2010 9:31 pm

removed cobra reinstalled from latest source and now it works! Maybe it's a problem with release version then...
zengeek
 
Posts: 8

Re: Some help

Postby Charles » Mon Oct 25, 2010 9:39 pm

Thanks for the update.

I have fixed a few bugs since the last release. And I'll fix a few more as well as applying some patches. And we'll have another release sometime in November.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Some help

Postby zengeek » Mon Oct 25, 2010 9:42 pm

great! Keep up the good work :D Cobra is now my official alternative to C# :)
zengeek
 
Posts: 8


Return to Discussion

Who is online

Users browsing this forum: No registered users and 79 guests

cron