/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#ifndef _PYGAME_H
#define _PYGAME_H
/** This header file includes all the definitions for the
** base pygame extensions. This header only requires
** SDL and Python includes. The reason for functions
** prototyped with #define's is to allow for maximum
** python portability. It also uses python as the
** runtime linker, which allows for late binding. For more
** information on this style of development, read the Python
** docs on this subject.
** http://www.python.org/doc/current/ext/using-cobjects.html
**
** If using this to build your own derived extensions,
** you'll see that the functions available here are mainly
** used to help convert between python objects and SDL objects.
** Since this library doesn't add a lot of functionality to
** the SDL libarary, it doesn't need to offer a lot either.
**
** When initializing your extension module, you must manually
** import the modules you want to use. (this is the part about
** using python as the runtime linker). Each module has its
** own import_xxx() routine. You need to perform this import
** after you have initialized your own module, and before
** you call any routines from that module. Since every module
** in pygame does this, there are plenty of examples.
**
** The base module does include some useful conversion routines
** that you are free to use in your own extension.
**
** When making changes, it is very important to keep the
** FIRSTSLOT and NUMSLOT constants up to date for each
** section. Also be sure not to overlap any of the slots.
** When you do make a mistake with this, it will result
** is a dereferenced NULL pointer that is easier to diagnose
** than it could be :]
**/
#if defined(HAVE_SNPRINTF) /* defined in python.h (pyerrors.h) and SDL.h (SDL_config.h) */
#undef HAVE_SNPRINTF /* remove GCC redefine warning */
#endif
// This must be before all else
#if defined(__SYMBIAN32__) && defined( OPENC )
#include <sys/types.h>
#if defined(__WINS__)
void* _alloca(size_t size);
# define alloca _alloca
#endif
#endif
/* This is unconditionally defined in Python.h */
#if defined(_POSIX_C_SOURCE)
#undef _POSIX_C_SOURCE
#endif
#include <Python.h>
/* Cobjects vanish in Python 3.2; so we will code as though we use capsules */
#if defined(Py_CAPSULE_H)
#define PG_HAVE_CAPSULE 1
#else
#define PG_HAVE_CAPSULE 0
#endif
#if defined(Py_COBJECT_H)
#define PG_HAVE_COBJECT 1
#else
#define PG_HAVE_COBJECT 0
#endif
#if !PG_HAVE_CAPSULE
#define PyCapsule_New(ptr, n, dfn) PyCObject_FromVoidPtr(ptr, dfn)
#define PyCapsule_GetPointer(obj, n) PyCObject_AsVoidPtr(obj)
#define PyCapsule_CheckExact(obj) PyCObject_Check(obj)
#endif
/* Pygame uses Py_buffer (PEP 3118) to exchange array information internally;
* define here as needed.
*/
#if !defined(PyBUF_SIMPLE)
typedef struct bufferinfo {
void *buf;
PyObject *obj;
Py_ssize_t len;
Py_ssize_t itemsize;
int readonly;
int ndim;
char *format;
Py_ssize_t *shape;
Py_ssize_t *strides;
Py_ssize_t *suboffsets;
void *internal;
} Py_buffer;
/* Flags for getting buffers */
#define PyBUF_SIMPLE 0
#define PyBUF_WRITABLE 0x0001
/* we used to include an E, backwards compatible alias */
#define PyBUF_WRITEABLE PyBUF_WRITABLE
#define PyBUF_FORMAT 0x0004
#define PyBUF_ND 0x0008
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
#define PyBUF_CONTIG_RO (PyBUF_ND)
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
#define PyBUF_READ 0x100
#define PyBUF_WRITE 0x200
#define PyBUF_SHADOW 0x400
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
typedef void (*releasebufferproc)(Py_buffer *);
#endif /* #if !defined(PyBUF_SIMPLE) */
/* Flag indicating a Pg_buffer; used for assertions within callbacks */
#ifndef NDEBUG
#define PyBUF_PYGAME 0x4000
#endif
#define PyBUF_HAS_FLAG(f, F) (((f) & (F)) == (F))
/* Array information exchange struct C type; inherits from Py_buffer
*
* Pygame uses its own Py_buffer derived C struct as an internal representation
* of an imported array buffer. The extended Py_buffer allows for a
* per-instance release callback,
*/
typedef void (*pybuffer_releaseproc)(Py_buffer *);
typedef struct pg_bufferinfo_s {
Py_buffer view;
PyObject *consumer; /* Input: Borrowed reference */
pybuffer_releaseproc release_buffer;
} Pg_buffer;
/* Operating system specific adjustments
*/
// No signal()
#if defined(__SYMBIAN32__) && defined(HAVE_SIGNAL_H)
#undef HAVE_SIGNAL_H
#endif
#if defined(HAVE_SNPRINTF)
#undef HAVE_SNPRINTF
#endif
#ifdef MS_WIN32 /*Python gives us MS_WIN32, SDL needs just WIN32*/
#ifndef WIN32
#define WIN32
#endif
#endif
/// Prefix when initializing module
#define MODPREFIX ""
/// Prefix when importing module
#define IMPPREFIX "pygame."
#ifdef __SYMBIAN32__
#undef MODPREFIX
#undef IMPPREFIX
// On Symbian there is no pygame package. The extensions are built-in or in sys\bin.
#define MODPREFIX "pygame_"
#define IMPPREFIX "pygame_"
#endif
#include <SDL.h>
/* macros used throughout the source */
#define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 3
# define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
# define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
# define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
#endif
/* Py_ssize_t availability. */
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
typedef inquiry lenfunc;
typedef intargfunc ssizeargfunc;
typedef intobjargproc ssizeobjargproc;
typedef intintargfunc ssizessizeargfunc;
typedef intintobjargproc ssizessizeobjargproc;
typedef getreadbufferproc readbufferproc;
typedef getwritebufferproc writebufferproc;
typedef getsegcountproc segcountproc;
typedef getcharbufferproc charbufferproc;
#endif
#define PyType_Init(x) (((x).ob_type) = &PyType_Type)
#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ( (a) > (b) ? (a) : (b))
#endif
#ifndef ABS
#define ABS(a) (((a) < 0) ? -(a) : (a))
#endif
/* test sdl initializations */
#define VIDEO_INIT_CHECK() \
if(!SDL_WasInit(SDL_INIT_VIDEO)) \
return RAISE(PyExc_SDLError, "video system not initialized")
#define CDROM_INIT_CHECK() \
if(!SDL_WasInit(SDL_INIT_CDROM)) \
return RAISE(PyExc_SDLError, "cdrom syst
没有合适的资源?快使用搜索试试~ 我知道了~
课程设计-基于python的汤姆猫小游戏源代码.rar
共2000个文件
py:1306个
jpg:428个
html:123个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 177 浏览量
2023-10-27
16:03:15
上传
评论 1
收藏 34.07MB RAR 举报
温馨提示
基于python写的小游戏,高分通过课程设计,希望对你有所帮助。
资源推荐
资源详情
资源评论
收起资源包目录
课程设计-基于python的汤姆猫小游戏源代码.rar (2000个子文件)
responsive.css 17KB
select2.css 17KB
base.css 16KB
select2.min.css 15KB
widgets.css 10KB
autocomplete.css 8KB
forms.css 8KB
changelists.css 6KB
rtl.css 4KB
responsive_rtl.css 2KB
login.css 1KB
ol3.css 657B
fonts.css 423B
dashboard.css 412B
_pygame.h 27KB
surface.h 13KB
camera.h 7KB
pgcompat.h 6KB
bitmask.h 5KB
scrap.h 4KB
freetype.h 4KB
mixer.h 2KB
pgbufferproxy.h 2KB
font.h 2KB
fastevents.h 2KB
pygame.h 1KB
pgarrinter.h 1KB
_surface.h 958B
_camera.h 840B
mask.h 620B
pgopengl.h 379B
technical_500.html 17KB
default_urlconf.html 16KB
readme.html 13KB
install.html 8KB
tabular.html 4KB
base.html 4KB
change_form.html 3KB
change_list.html 3KB
index.html 3KB
technical_404.html 2KB
delete_confirmation.html 2KB
change_password.html 2KB
delete_selected_confirmation.html 2KB
stacked.html 2KB
password_change_form.html 2KB
openlayers.html 2KB
login.html 2KB
openlayers.html 2KB
model_detail.html 2KB
fieldset.html 2KB
template_filter_index.html 2KB
template_tag_index.html 2KB
view_index.html 2KB
logos.html 2KB
change_list_results.html 2KB
object_history.html 1KB
related_widget_wrapper.html 1KB
related_widget_wrapper.html 1KB
password_reset_confirm.html 1KB
bookmarklets.html 1KB
model_index.html 1KB
index.html 1KB
search_form.html 1KB
actions.html 1012B
template_detail.html 995B
password_reset_form.html 970B
view_detail.html 896B
submit_line.html 790B
missing_docutils.html 734B
password_change_done.html 671B
password_reset_done.html 669B
password_reset_email.html 582B
clearable_file_input.html 574B
pagination.html 554B
500.html 527B
password_reset_complete.html 505B
clearable_file_input.html 467B
clearable_file_input.html 467B
multiple_input.html 462B
invalid_setup.html 437B
multiple_input.html 431B
app_index.html 385B
select.html 384B
openlayers-osm.html 378B
logged_out.html 374B
date_hierarchy.html 372B
select.html 365B
popup_response.html 358B
foreign_key_raw_id.html 346B
filter.html 330B
base_site.html 316B
add_form.html 310B
404.html 268B
prepopulated_fields_js.html 245B
split_datetime.html 240B
url.html 226B
input_option.html 205B
input_option.html 205B
input.html 191B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
等天晴i
- 粉丝: 5080
- 资源: 10万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功