Coder Social home page Coder Social logo

vsdl2's Introduction

vsdl2's People

Contributors

adlesh avatar nsauzede avatar spytheman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vsdl2's Issues

Problem with example tvintris.v

I made some tests
vlang/v#6133

v-0.1.29\v\examples\tvintris>v install nsauzede.vsdl2
Error 10057 sending data to server (1)
Error performing handshake
Unhandled Exception 0xC0000005
print_backtrace_skipping_top_frames is not implemented
v-0.1.29\v\examples\tvintris>v run tvintris.v
tvintris.v:22:2: warning: const names cannot contain uppercase letters, use snake_case instead
   20 | const (
   21 |     vsdl2_version = vsdl2.version
   22 |     Title = 'tVintris'
      |     ~~~~~
   23 |     BASE = os.dir( os.real_path( os.executable() ) )
   24 |     font_name = BASE + '/fonts/RobotoMono-Regular.ttf'
tvintris.v:23:2: warning: const names cannot contain uppercase letters, use snake_case instead
   21 |     vsdl2_version = vsdl2.version
   22 |     Title = 'tVintris'
   23 |     BASE = os.dir( os.real_path( os.executable() ) )
      |     ~~~~
   24 |     font_name = BASE + '/fonts/RobotoMono-Regular.ttf'
   25 |     music_name = BASE + '/sounds/TwintrisThosenine.mod'
tvintris.v:29:2: warning: const names cannot contain uppercase letters, use snake_case instead
   27 |     snd_line_name = BASE + '/sounds/single.wav'
   28 |     snd_double_name = BASE + '/sounds/triple.wav'
   29 |     VLogo = BASE + '/images/v-logo_30_30.png'
      |     ~~~~~
   30 |     BlockSize = 20 // pixels
   31 |     FieldHeight = 20 // # of blocks
tvintris.v:30:2: warning: const names cannot contain uppercase letters, use snake_case instead
   28 |     snd_double_name = BASE + '/sounds/triple.wav'
   29 |     VLogo = BASE + '/images/v-logo_30_30.png'
   30 |     BlockSize = 20 // pixels
      |     ~~~~~~~~~
   31 |     FieldHeight = 20 // # of blocks
   32 |     FieldWidth = 10
tvintris.v:31:2: warning: const names cannot contain uppercase letters, use snake_case instead
   29 |     VLogo = BASE + '/images/v-logo_30_30.png'
   30 |     BlockSize = 20 // pixels
   31 |     FieldHeight = 20 // # of blocks
      |     ~~~~~~~~~~~
   32 |     FieldWidth = 10
   33 |     TetroSize = 4
tvintris.v:32:2: warning: const names cannot contain uppercase letters, use snake_case instead
   30 |     BlockSize = 20 // pixels
   31 |     FieldHeight = 20 // # of blocks
   32 |     FieldWidth = 10
      |     ~~~~~~~~~~
   33 |     TetroSize = 4
   34 |     WinWidth = BlockSize * FieldWidth * 3
tvintris.v:33:2: warning: const names cannot contain uppercase letters, use snake_case instead
   31 |     FieldHeight = 20 // # of blocks
   32 |     FieldWidth = 10
   33 |     TetroSize = 4
      |     ~~~~~~~~~
   34 |     WinWidth = BlockSize * FieldWidth * 3
   35 |     WinHeight = BlockSize * FieldHeight
tvintris.v:34:2: warning: const names cannot contain uppercase letters, use snake_case instead
   32 |     FieldWidth = 10
   33 |     TetroSize = 4
   34 |     WinWidth = BlockSize * FieldWidth * 3
      |     ~~~~~~~~
   35 |     WinHeight = BlockSize * FieldHeight
   36 |     TimerPeriod = 250 // ms
tvintris.v:35:2: warning: const names cannot contain uppercase letters, use snake_case instead
   33 |     TetroSize = 4
   34 |     WinWidth = BlockSize * FieldWidth * 3
   35 |     WinHeight = BlockSize * FieldHeight
      |     ~~~~~~~~~
   36 |     TimerPeriod = 250 // ms
   37 |     TextSize = 16
tvintris.v:36:2: warning: const names cannot contain uppercase letters, use snake_case instead
   34 |     WinWidth = BlockSize * FieldWidth * 3
   35 |     WinHeight = BlockSize * FieldHeight
   36 |     TimerPeriod = 250 // ms
      |     ~~~~~~~~~~~
   37 |     TextSize = 16
   38 |     AudioBufSize = 1024
tvintris.v:37:2: warning: const names cannot contain uppercase letters, use snake_case instead
   35 |     WinHeight = BlockSize * FieldHeight
   36 |     TimerPeriod = 250 // ms
   37 |     TextSize = 16
      |     ~~~~~~~~
   38 |     AudioBufSize = 1024
   39 |
tvintris.v:38:2: warning: const names cannot contain uppercase letters, use snake_case instead
   36 |     TimerPeriod = 250 // ms
   37 |     TextSize = 16
   38 |     AudioBufSize = 1024
      |     ~~~~~~~~~~~~
   39 |
   40 |     P2FIRE = C.SDLK_l
tvintris.v:40:2: warning: const names cannot contain uppercase letters, use snake_case instead
   38 |     AudioBufSize = 1024
   39 |
   40 |     P2FIRE = C.SDLK_l
      |     ~~~~~~
   41 |     P2UP = C.SDLK_UP
   42 |     P2DOWN = C.SDLK_DOWN
tvintris.v:41:2: warning: const names cannot contain uppercase letters, use snake_case instead
   39 |
   40 |     P2FIRE = C.SDLK_l
   41 |     P2UP = C.SDLK_UP
      |     ~~~~
   42 |     P2DOWN = C.SDLK_DOWN
   43 |     P2LEFT = C.SDLK_LEFT
tvintris.v:42:2: warning: const names cannot contain uppercase letters, use snake_case instead
   40 |     P2FIRE = C.SDLK_l
   41 |     P2UP = C.SDLK_UP
   42 |     P2DOWN = C.SDLK_DOWN
      |     ~~~~~~
   43 |     P2LEFT = C.SDLK_LEFT
   44 |     P2RIGHT = C.SDLK_RIGHT
tvintris.v:43:2: warning: const names cannot contain uppercase letters, use snake_case instead
   41 |     P2UP = C.SDLK_UP
   42 |     P2DOWN = C.SDLK_DOWN
   43 |     P2LEFT = C.SDLK_LEFT
      |     ~~~~~~
   44 |     P2RIGHT = C.SDLK_RIGHT
   45 |
tvintris.v:44:2: warning: const names cannot contain uppercase letters, use snake_case instead
   42 |     P2DOWN = C.SDLK_DOWN
   43 |     P2LEFT = C.SDLK_LEFT
   44 |     P2RIGHT = C.SDLK_RIGHT
      |     ~~~~~~~
   45 |
   46 |     P1FIRE = C.SDLK_s
tvintris.v:46:2: warning: const names cannot contain uppercase letters, use snake_case instead
   44 |     P2RIGHT = C.SDLK_RIGHT
   45 |
   46 |     P1FIRE = C.SDLK_s
      |     ~~~~~~
   47 |     P1UP = C.SDLK_w
   48 |     P1DOWN = C.SDLK_x
tvintris.v:47:2: warning: const names cannot contain uppercase letters, use snake_case instead
   45 |
   46 |     P1FIRE = C.SDLK_s
   47 |     P1UP = C.SDLK_w
      |     ~~~~
   48 |     P1DOWN = C.SDLK_x
   49 |     P1LEFT = C.SDLK_a
tvintris.v:48:2: warning: const names cannot contain uppercase letters, use snake_case instead
   46 |     P1FIRE = C.SDLK_s
   47 |     P1UP = C.SDLK_w
   48 |     P1DOWN = C.SDLK_x
      |     ~~~~~~
   49 |     P1LEFT = C.SDLK_a
   50 |     P1RIGHT = C.SDLK_d
tvintris.v:49:2: warning: const names cannot contain uppercase letters, use snake_case instead
   47 |     P1UP = C.SDLK_w
   48 |     P1DOWN = C.SDLK_x
   49 |     P1LEFT = C.SDLK_a
      |     ~~~~~~
   50 |     P1RIGHT = C.SDLK_d
   51 |
tvintris.v:50:2: warning: const names cannot contain uppercase letters, use snake_case instead
   48 |     P1DOWN = C.SDLK_x
   49 |     P1LEFT = C.SDLK_a
   50 |     P1RIGHT = C.SDLK_d
      |     ~~~~~~~
   51 |
   52 |     NJOYMAX = 2
tvintris.v:52:2: warning: const names cannot contain uppercase letters, use snake_case instead
   50 |     P1RIGHT = C.SDLK_d
   51 |
   52 |     NJOYMAX = 2
      |     ~~~~~~~
   53 |     // joystick name => enter your own device name
   54 |     JOYP1NAME = 'Generic X-Box pad'
tvintris.v:54:2: warning: const names cannot contain uppercase letters, use snake_case instead
   52 |     NJOYMAX = 2
   53 |     // joystick name => enter your own device name
   54 |     JOYP1NAME = 'Generic X-Box pad'
      |     ~~~~~~~~~
   55 |     // following are joystick button number
   56 |     JBP1FIRE = 1
tvintris.v:56:2: warning: const names cannot contain uppercase letters, use snake_case instead
   54 |     JOYP1NAME = 'Generic X-Box pad'
   55 |     // following are joystick button number
   56 |     JBP1FIRE = 1
      |     ~~~~~~~~
   57 |     // following are joystick hat value
   58 |     JHP1UP = 1
tvintris.v:58:2: warning: const names cannot contain uppercase letters, use snake_case instead
   56 |     JBP1FIRE = 1
   57 |     // following are joystick hat value
   58 |     JHP1UP = 1
      |     ~~~~~~
   59 |     JHP1DOWN = 4
   60 |     JHP1LEFT = 8
tvintris.v:59:2: warning: const names cannot contain uppercase letters, use snake_case instead
   57 |     // following are joystick hat value
   58 |     JHP1UP = 1
   59 |     JHP1DOWN = 4
      |     ~~~~~~~~
   60 |     JHP1LEFT = 8
   61 |     JHP1RIGHT = 3
tvintris.v:60:2: warning: const names cannot contain uppercase letters, use snake_case instead
   58 |     JHP1UP = 1
   59 |     JHP1DOWN = 4
   60 |     JHP1LEFT = 8
      |     ~~~~~~~~
   61 |     JHP1RIGHT = 3
   62 |
tvintris.v:61:2: warning: const names cannot contain uppercase letters, use snake_case instead
   59 |     JHP1DOWN = 4
   60 |     JHP1LEFT = 8
   61 |     JHP1RIGHT = 3
      |     ~~~~~~~~~
   62 |
   63 |     // joystick name => enter your own device name
tvintris.v:64:2: warning: const names cannot contain uppercase letters, use snake_case instead
   62 |
   63 |     // joystick name => enter your own device name
   64 |     JOYP2NAME = 'RedOctane Guitar Hero X-plorer'
      |     ~~~~~~~~~
   65 |     // following are joystick button number
   66 |     JBP2FIRE = 0
tvintris.v:66:2: warning: const names cannot contain uppercase letters, use snake_case instead
   64 |     JOYP2NAME = 'RedOctane Guitar Hero X-plorer'
   65 |     // following are joystick button number
   66 |     JBP2FIRE = 0
      |     ~~~~~~~~
   67 |     // following are joystick hat value
   68 |     JHP2UP = 4
tvintris.v:68:2: warning: const names cannot contain uppercase letters, use snake_case instead
   66 |     JBP2FIRE = 0
   67 |     // following are joystick hat value
   68 |     JHP2UP = 4
      |     ~~~~~~
   69 |     JHP2DOWN = 1
   70 |     JHP2LEFT = 8
tvintris.v:69:2: warning: const names cannot contain uppercase letters, use snake_case instead
   67 |     // following are joystick hat value
   68 |     JHP2UP = 4
   69 |     JHP2DOWN = 1
      |     ~~~~~~~~
   70 |     JHP2LEFT = 8
   71 |     JHP2RIGHT = 2
tvintris.v:70:2: warning: const names cannot contain uppercase letters, use snake_case instead
   68 |     JHP2UP = 4
   69 |     JHP2DOWN = 1
   70 |     JHP2LEFT = 8
      |     ~~~~~~~~
   71 |     JHP2RIGHT = 2
   72 | )
tvintris.v:71:2: warning: const names cannot contain uppercase letters, use snake_case instead
   69 |     JHP2DOWN = 1
   70 |     JHP2LEFT = 8
   71 |     JHP2RIGHT = 2
      |     ~~~~~~~~~
   72 | )
   73 |
tvintris.v:112:2: warning: const names cannot contain uppercase letters, use snake_case instead
  110 |     ]
  111 |     // Each tetro has its unique color
  112 |     Colors = [
      |     ~~~~~~
  113 |         vsdl2.Color{byte(0), byte(0), byte(0), byte(0)},        // unused ?
  114 |         vsdl2.Color{byte(0), byte(0x62), byte(0xc0), byte(0)},    // quad : darkblue 0062c0
tvintris.v:124:2: warning: const names cannot contain uppercase letters, use snake_case instead
  122 |     ]
  123 |     // Background color
  124 |     BackgroundColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)}
      |     ~~~~~~~~~~~~~~~
  125 | //    BackgroundColor = vsdl2.Color{byte(255), byte(255), byte(255), byte(0)}
  126 |     // Foreground color
tvintris.v:127:2: warning: const names cannot contain uppercase letters, use snake_case instead
  125 | //    BackgroundColor = vsdl2.Color{byte(255), byte(255), byte(255), byte(0)}
  126 |     // Foreground color
  127 |     ForegroundColor = vsdl2.Color{byte(0), byte(170), byte(170), byte(0)}
      |     ~~~~~~~~~~~~~~~
  128 | //    ForegroundColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)}
  129 |     // Text color
tvintris.v:130:2: warning: const names cannot contain uppercase letters, use snake_case instead
  128 | //    ForegroundColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)}
  129 |     // Text color
  130 |     TextColor = vsdl2.Color{byte(0xca), byte(0x7d), byte(0x5f), byte(0)}
      |     ~~~~~~~~~
  131 | //    TextColor = vsdl2.Color{byte(0), byte(0), byte(0), byte(0)}
  132 | )
tvintris.v:247:9: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  245 |
  246 |
  247 | fn (sdl mut SdlContext) set_sdl_context(w int, h int, title string) {
      |         ~~~
  248 |     C.SDL_Init(C.SDL_INIT_VIDEO | C.SDL_INIT_AUDIO | C.SDL_INIT_JOYSTICK)
  249 |     C.atexit(C.SDL_Quit)
tvintris.v:463:10: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  461 |         idle space fire
  462 | }
  463 | fn (game mut Game) handle_key(key int) {
      |          ~~~
  464 |     // global keys
  465 |     mut action := Action.idle
tvintris.v:506:10: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  504 | }
  505 |
  506 | fn (game mut Game) handle_jbutton(jb int, joyid int) {
      |          ~~~
  507 |     if joyid != game.joy_id {
  508 |         return
tvintris.v:528:10: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  526 | }
  527 |
  528 | fn (game mut Game) handle_jhat(jh int, jv int, joyid int) {
      |          ~~~
  529 |     if joyid != game.joy_id {
  530 |         return
tvintris.v:544:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  542 | }
  543 |
  544 | fn (g mut Game) init_game() {
      |       ~~~
  545 |     g.score = 0
  546 |     g.tetro_total = 0
tvintris.v:567:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  565 | }
  566 |
  567 | fn (g mut Game) parse_tetros() {
      |       ~~~
  568 |     for btetros in b_tetros {
  569 |         for btetro in btetros {
tvintris.v:577:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  575 | }
  576 |
  577 | fn (g mut Game) run() {
      |       ~~~
  578 |     for {
  579 |         if g.state == .running {
tvintris.v:600:10: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  598 | }
  599 |
  600 | fn (game mut Game) rotate_tetro() {
      |          ~~~
  601 |     // Rotate the tetro
  602 |     old_rotation_idx := game.rotation_idx
tvintris.v:617:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  615 | }
  616 |
  617 | fn (g mut Game) move_tetro() {
      |       ~~~
  618 |     // Check each block in current tetro
  619 |     for block in g.tetro {
tvintris.v:643:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  641 | }
  642 |
  643 | fn (g mut Game) move_right(dx int) bool {
      |       ~~~
  644 |     // Reached left/right edge or another tetro?
  645 |     for i := 0; i < TetroSize; i++ {
tvintris.v:686:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  684 |
  685 | // Draw a rand tetro index
  686 | fn (g mut Game) rand_tetro() int {
      |       ~~~
  687 |     cur := g.tetro_next
  688 |     g.tetro_next = rand_r(&g.seed)
tvintris.v:694:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  692 |
  693 | // Place a new tetro on top
  694 | fn (g mut Game) generate_tetro() {
      |       ~~~
  695 |     g.pos_y = 0
  696 |     g.pos_x = FieldWidth / 2 - TetroSize / 2
tvintris.v:706:7: warning: use `(mut f Foo)` instead of `(f mut Foo)`
  704 |
  705 | // Get the right tetro from cache
  706 | fn (g mut Game) get_tetro() {
      |       ~~~
  707 |     idx := g.tetro_idx * TetroSize * TetroSize + g.rotation_idx * TetroSize
  708 |     g.tetro = g.tetros_cache[idx .. idx + TetroSize]
tvintris.v:10:8: warning: module 'rand' is imported but never used
    8 | module main
    9 |
   10 | import rand
      |        ~~~~
   11 | import time
   12 | import os
builder error: cannot import module "nsauzede.vsdl2" (not found)

cc: error: sdl2-config: No such file or directory

I'm running debian buster.

Your code is missing the linux backtick (command substitution) symbole. I modified line 7 from

#flag linux sdl2-config --cflags --libs -lSDL2_ttf -lSDL2_mixer -lSDL2_image

to

#flag linux sdl2-config --cflags --libs -lSDL2_ttf -lSDL2_mixer -lSDL2_image

and it works as expected.

Integrate V-UI once available for UI components

Just wanted to clean this off of the chat and keep it focussed. I think you're spot on in your thought about keeping TTF (and by extension UI) in the realm of existing libraries. Obviously we're waiting (anxiously) for a "V UI" drop from @medvednikov, but this is a critical topic... And I think that should be considered broadly in order to keep things aligned perhaps with the "one way to do things" philosophy of V. (I realize that it won't always work and won't always be true, but where possible it seems that libraries should aim for this too.)

It would be a truly beautiful thing for cross pollination and utilization to have a primary user interface kit that can be used in conjunction with games and simultaneously bring game development INTO app development so that they're not (semi)mutually exclusive. There's no reason to not cooperate where possible and this is one key area where I think cooperation is key.

Speaking from our own experience, we've been really frustrated by (and this is a big point of pain) Unity, for example, not having a really solidly cohesive UI library that facilitates broader app functionality and native integration when using Unity.

I'm (totally) guessing that aside from having the native UI appearance in V UI, it will also have the ability to make custom user interfaces if desired (that seems like a pretty common sense approach). If so, it would seem to me, that this would facilitate both styles in the future with a focus on sanity via native UI by default with the ability to customize for more esoteric and peculiar game interfaces.

Personally I'm super excited about this blending of app-game modality.

Drop Sdl from struct names

Could we think about dropping Sdl from the struct names? It seems a little redundant as the module's name will serve as reminder and prevent namespace conflicts. It would match the pattern of dropping the SDL_ prefix when translating to v. I'd be glad to do it myself; just wanted your input.

struct SdlRect {

}
... becomes
struct Rect {

}

and vsdl2.SdlRect{} becomes vsdl2.Rect{}

can't run tvintris example on windows

what i do:

  1. v install nsauzede.vsdl2
    2 install msys2
    3 do [pacman -S mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_image] with msys2 console

run example
v run main_v.v

got me an arror:
builder error: 'strings.h' not found

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.